diff options
Diffstat (limited to 'deploy-command.js')
| -rw-r--r-- | deploy-command.js | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/deploy-command.js b/deploy-command.js index fd9de7a..0b57507 100644 --- a/deploy-command.js +++ b/deploy-command.js @@ -1,6 +1,5 @@ import fs, { readFileSync } from 'node:fs'; -import { REST } from '@discordjs/rest'; -import { Routes } from 'discord-api-types/v10'; +import { REST, Routes } from 'discord.js'; // import config from './config.json' assert {type: 'json'} const { clientID, token } = JSON.parse(readFileSync('./config.json')); @@ -12,8 +11,22 @@ for (const file of commandFiles) { commands.push(command.data.toJSON()); } -const rest = new REST({ version: '10' }).setToken(token); +const rest = new REST().setToken(token); -rest.put(Routes.applicationCommands(clientID), { body: commands }) - .then(() => console.log('Successfully registered application commands.')) - .catch(console.error); +// 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); + } +})(); |
