Convert to Typescript
This commit is contained in:
25
src/register-slash-commands.ts
Normal file
25
src/register-slash-commands.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { REST, Routes } from 'discord.js';
|
||||
import { commands } from './commands';
|
||||
import config from './config';
|
||||
|
||||
// Register all slash commands, globally across all Guilds.
|
||||
const commandData = Object.values(commands).map(
|
||||
(command) => command.data.toJSON() as any
|
||||
);
|
||||
|
||||
const rest = new REST().setToken(config.discordApiKey);
|
||||
|
||||
try {
|
||||
console.log('Started refreshing application (/) commands.');
|
||||
|
||||
// Refresh all slash commands globally.
|
||||
rest.put(Routes.applicationCommands(config.discordApplicationId), {
|
||||
body: commandData,
|
||||
});
|
||||
|
||||
// Exit the process.
|
||||
process.exit();
|
||||
} catch (error) {
|
||||
// And of course, make sure you catch and log any errors!
|
||||
console.error(error);
|
||||
}
|
||||
Reference in New Issue
Block a user