Added Command Deployment via REST
This commit is contained in:
parent
d032b5dba8
commit
abb422c7f1
4 changed files with 369 additions and 6 deletions
22
deploy-commands.js
Normal file
22
deploy-commands.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
require('dotenv').config();
|
||||
const { REST, SlashCommandBuilder, Routes } = require('discord.js');
|
||||
const clientId = process.env.CLIENT_ID;
|
||||
const guildId = process.env.GUILD_ID;
|
||||
const token = process.env.TOKEN;
|
||||
|
||||
const commands = [
|
||||
new SlashCommandBuilder().setName('ping').setDescription('Replies with pong!'),
|
||||
new SlashCommandBuilder().setName('server').setDescription('Replies with server info!'),
|
||||
new SlashCommandBuilder().setName('user').setDescription('Replies with user info!'),
|
||||
]
|
||||
.map(command => command.toJSON());
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken(token);
|
||||
|
||||
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] })
|
||||
.then((data) => console.log('Removed all commands from guilds'))
|
||||
.catch(console.error);
|
||||
|
||||
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
|
||||
.then((data) => console.log(`Successfully registered ${data.length} application commands.`))
|
||||
.catch(console.error);
|
Loading…
Add table
Add a link
Reference in a new issue