deploy-commands.js (view raw)
1const { SlashCommandBuilder, Routes } = require('discord.js');
2const { REST } = require('@discordjs/rest');
3const { clientId, guildId, token } = require('./config.json');
4
5const commands = [
6 // new SlashCommandBuilder().setName('ping').setDescription('Replies with pong!'),
7 // new SlashCommandBuilder().setName('server').setDescription('Replies with server info!'),
8 // new SlashCommandBuilder().setName('user').setDescription('Replies with user info!'),
9 new SlashCommandBuilder().setName('outro').setDescription('Leave voice channel with an outro.'),
10]
11 .map(command => command.toJSON());
12
13const rest = new REST({ version: '10' }).setToken(token);
14
15/*
16rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
17 .then((data) => console.log(`Successfully registered ${data.length} application commands.`))
18 .catch(console.error);
19 */
20rest.put(Routes.applicationCommands(clientId), { body: commands })
21 .then((data) => console.log(`Successfully registered ${data.length} application commands.`))
22 .catch(console.error);