2023-03-25 13:09:44 -04:00
|
|
|
require("dotenv").config();
|
|
|
|
const { glob } = require("glob");
|
|
|
|
const { promisify } = require("util");
|
|
|
|
const globPromise = promisify(glob);
|
|
|
|
|
|
|
|
module.exports = async (client) => {
|
|
|
|
// Slash Commands
|
|
|
|
const slashCommands = await globPromise(`${process.cwd()}/commands/*/*.js`);
|
|
|
|
const arrayOfSlashCommands = [];
|
|
|
|
slashCommands.map((value) => {
|
|
|
|
const file = require(value);
|
|
|
|
const splitted = value.split("/");
|
|
|
|
const directory = splitted[splitted.length - 2];
|
|
|
|
|
|
|
|
if (!file?.name) return;
|
|
|
|
|
|
|
|
const properties = { directory, ...file };
|
|
|
|
client.slashCommands.set(file.name, properties);
|
|
|
|
|
|
|
|
if (["MESSAGE", "USER"].includes(file.type)) delete file.description;
|
|
|
|
arrayOfSlashCommands.push(file);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Events
|
|
|
|
const eventFiles = await globPromise(`${process.cwd()}/events/*.js`);
|
|
|
|
eventFiles.map((value) => require(value));
|
|
|
|
|
|
|
|
// Slash Commands Register
|
|
|
|
client.on("ready", async () => {
|
|
|
|
// // Register for a single guild
|
|
|
|
// await client.guilds.cache.get("GUIDIDHERE").commands.set(arrayOfSlashCommands);
|
|
|
|
|
2023-04-07 17:27:13 -04:00
|
|
|
// Clear previous commands (for changes to installed models)
|
|
|
|
await client.application.commands.set([]);
|
|
|
|
|
2023-03-25 13:09:44 -04:00
|
|
|
// Register for all the guilds the bot is in
|
|
|
|
await client.application.commands.set(arrayOfSlashCommands);
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|