added proper modal handler and raidplan
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
|
||||
module.exports = (client) => {
|
||||
const modalsPath = path.join(
|
||||
__dirname,
|
||||
"../modals"
|
||||
);
|
||||
|
||||
if (!fs.existsSync(modalsPath)) {
|
||||
console.log(
|
||||
`[WARNING] Modal directory not found: ${modalsPath}`
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const modalFiles = fs
|
||||
.readdirSync(modalsPath)
|
||||
.filter(file =>
|
||||
file.endsWith(".js")
|
||||
);
|
||||
|
||||
let count = 0;
|
||||
|
||||
for (const file of modalFiles) {
|
||||
const filePath = path.join(
|
||||
modalsPath,
|
||||
file
|
||||
);
|
||||
|
||||
const modal = require(filePath);
|
||||
|
||||
if (
|
||||
!modal.customId ||
|
||||
typeof modal.execute !== "function"
|
||||
) {
|
||||
console.log(
|
||||
`[WARNING] Modal ${file} is missing "customId" or "execute".`
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
client.modals.set(
|
||||
modal.customId,
|
||||
modal
|
||||
);
|
||||
|
||||
console.log(
|
||||
`[MODAL] Registered "${modal.customId}" from ${file}`
|
||||
);
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
console.log(
|
||||
`[${count}] Modal(s) initialized`
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user