@skybloxsystems/ticket-bot
Version:
43 lines (32 loc) • 1.17 kB
JavaScript
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { token } = require('../slappey.json');
const fs = require('fs');
const commands = [];
const commandList = new Map();
const { config } = require('../../index')
const locationoffiles = './node_modules/@skybloxsystems/ticket-bot/Bot/src/Slash-Commands'
module.exports = () => {
const commandFiles = fs.readdirSync(locationoffiles).filter(file => file.endsWith('.js'));
// Place your client and guild ids here
const clientId = config.bot.botClientId;
for (const file of commandFiles) {
const command = require(`./Slash-Commands/${file}`);
commands.push(command.data.toJSON());
commandList.set(command.data.name, command.run);
}
const rest = new REST({ version: '9' }).setToken(token);
(async () => {
try {
console.log('Started refreshing application (/) commands.');
await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
}
module.exports.commands = commandList;