Files
BattleBot/deploy-commands.js
2024-10-18 09:44:42 -05:00

40 lines
1.3 KiB
JavaScript

// deploycommands.js
const { REST, Routes, SlashCommandBuilder } = require('discord.js');
require('dotenv').config();
const commands = [
new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
new SlashCommandBuilder()
.setName('finduser')
.setDescription('Find a user by username')
.addStringOption(option =>
option.setName('username')
.setDescription('The username to search for')
.setRequired(true))
.addStringOption(option =>
option.setName('game')
.setDescription('Specify a game to view stats for')
.setRequired(false)),
// Add more commands here
];
const rest = new REST({ version: '10' }).setToken(process.env.BOT_TOKEN);
(async () => {
try {
console.log('Started refreshing application (/) commands.');
console.log('Commands to be deployed:', commands.map(cmd => cmd.name));
await rest.put(
Routes.applicationCommands(process.env.CLIENT_ID),
{ body: commands.map(command => command.toJSON()) },
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();