70 lines
2.7 KiB
JavaScript
70 lines
2.7 KiB
JavaScript
// deploy-commands.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)),
|
|
new SlashCommandBuilder()
|
|
.setName('matchhistory')
|
|
.setDescription('View match history')
|
|
.addStringOption(option =>
|
|
option.setName('username')
|
|
.setDescription('The username to search for')
|
|
.setRequired(true))
|
|
.addStringOption(option =>
|
|
option.setName('game')
|
|
.setDescription('Filter by game')
|
|
.setRequired(false)),
|
|
new SlashCommandBuilder()
|
|
.setName('subscribe')
|
|
.setDescription('Subscribe to notifications for a game')
|
|
.addStringOption(option =>
|
|
option.setName('game')
|
|
.setDescription('The game to subscribe to')
|
|
.setRequired(true))
|
|
.addChannelOption(option =>
|
|
option.setName('channel')
|
|
.setDescription('The channel to receive notifications (default: current channel)')
|
|
.setRequired(false)),
|
|
new SlashCommandBuilder()
|
|
.setName('unsubscribe')
|
|
.setDescription('Unsubscribe from notifications for a game')
|
|
.addStringOption(option =>
|
|
option.setName('game')
|
|
.setDescription('The game to unsubscribe from')
|
|
.setRequired(true)),
|
|
new SlashCommandBuilder()
|
|
.setName('listsubscriptions')
|
|
.setDescription('List all active subscriptions for this server'),
|
|
];
|
|
|
|
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);
|
|
}
|
|
})(); |