Moved code to src folder

This commit is contained in:
2023-11-23 12:38:55 +01:00
parent 932bce6057
commit 0eeb48b2dd
68 changed files with 59 additions and 70 deletions

View File

@@ -0,0 +1,24 @@
const { Events } = require("discord.js")
const path = require("path")
const fs = require("fs")
/** @param { import('discord.js').Client } client */
function loadModalEvents(client) {
const modalPath = path.join(__dirname, "..", "..", "events", "modals")
const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith(".js"))
for (const file of modalFiles) {
const filePath = path.join(modalPath, file)
const modal = require(filePath)
if ("name" in modal && "execute" in modal && modal.type === "modal") {
client.on(Events.InteractionCreate, modal.execute)
} else {
console.log(`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`)
}
}
}
module.exports = { loadModalEvents }