Added Command Deployment via REST

This commit is contained in:
Sebastian Fischlmayr 2022-10-07 12:02:35 +02:00
parent d032b5dba8
commit abb422c7f1
Signed by: Maverick
GPG key ID: 6379E413924A4E77
4 changed files with 369 additions and 6 deletions

22
deploy-commands.js Normal file
View 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);