2022-12-11 02:22:11 +00:00
|
|
|
// taken from https://discordjs.guide/
|
|
|
|
|
|
|
|
const { REST, Routes } = require('discord.js');
|
|
|
|
const { clientId, token } = require('../botconfig.json');
|
2022-12-12 01:25:48 +00:00
|
|
|
const guildId = '413591792185769984';
|
2022-12-11 02:22:11 +00:00
|
|
|
const read = require('fs-readdir-recursive');
|
|
|
|
const commands = [];
|
|
|
|
const commandFiles = read('./commands').filter(file => file.endsWith('.js'));
|
|
|
|
|
|
|
|
for (const file of commandFiles) {
|
2022-12-12 01:25:48 +00:00
|
|
|
const command = new (require(__dirname + '/commands/' + file))(file.substr(file.indexOf('/') + 1).slice(0, -3), file.substr(0, file.indexOf('/')));
|
|
|
|
commands.push({
|
|
|
|
name: command.name,
|
|
|
|
description: command.description,
|
|
|
|
options: command.options,
|
|
|
|
permissions: command.permissions,
|
|
|
|
dm_permission: command.dm_permission
|
|
|
|
});
|
2022-12-11 02:22:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const rest = new REST({ version: '10' }).setToken(token);
|
|
|
|
|
|
|
|
(async () => {
|
2022-12-12 01:25:48 +00:00
|
|
|
try {
|
|
|
|
console.log(`Started refreshing ${commands.length} application (/) commands.`);
|
2022-12-11 02:22:11 +00:00
|
|
|
|
2022-12-12 01:25:48 +00:00
|
|
|
const data = await rest.put(
|
|
|
|
Routes.applicationGuildCommands(clientId, guildId),
|
|
|
|
{ body: commands },
|
|
|
|
);
|
2022-12-11 02:22:11 +00:00
|
|
|
|
2022-12-12 01:25:48 +00:00
|
|
|
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
2022-12-11 02:22:11 +00:00
|
|
|
})();
|