2022-07-09 22:14:38 -04:00
|
|
|
import fs, { readFileSync } from 'node:fs';
|
2024-02-15 20:19:36 -05:00
|
|
|
import { REST, Routes } from 'discord.js';
|
2022-07-12 19:49:42 -04:00
|
|
|
const { clientID, token } = JSON.parse(readFileSync('./config.json'));
|
2022-03-26 13:43:03 -04:00
|
|
|
|
|
|
|
const commands = [];
|
2022-12-18 22:31:04 -05:00
|
|
|
const commandFiles = fs.readdirSync('./Commands').filter(file => file.endsWith('.js'));
|
2022-03-26 13:43:03 -04:00
|
|
|
|
|
|
|
for (const file of commandFiles) {
|
2022-12-18 22:31:04 -05:00
|
|
|
const { default: command } = await import(`./Commands/${file}`);
|
2022-07-09 22:14:38 -04:00
|
|
|
commands.push(command.data.toJSON());
|
2022-03-26 13:43:03 -04:00
|
|
|
}
|
|
|
|
|
2024-02-15 20:19:36 -05:00
|
|
|
const rest = new REST().setToken(token);
|
2022-03-26 13:43:03 -04:00
|
|
|
|
2024-02-15 20:19:36 -05:00
|
|
|
// and deploy your commands!
|
|
|
|
(async() => {
|
|
|
|
try {
|
|
|
|
console.log(`Started refreshing ${commands.length} application (/) commands.`);
|
|
|
|
|
|
|
|
// The put method is used to fully refresh all commands in the guild with the current set
|
|
|
|
const data = await rest.put(
|
|
|
|
Routes.applicationCommands(clientID),
|
|
|
|
{ body: commands }
|
|
|
|
);
|
|
|
|
|
|
|
|
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
|
|
|
|
} catch (error) {
|
|
|
|
// And of course, make sure you catch and log any errors!
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
})();
|