Added support for type commands

This commit is contained in:
Sebastian Fischlmayr 2022-10-07 13:54:17 +02:00
parent abb422c7f1
commit 4c853ae503
Signed by: Maverick
GPG key ID: 6379E413924A4E77
3 changed files with 39 additions and 14 deletions

View file

@ -5,9 +5,19 @@ 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!'),
new SlashCommandBuilder()
.setName('generate')
.setDescription('Generate something.')
.addStringOption(option =>
option.setName('type')
.setDescription('The type of thing to generate.')
.setRequired(true)
.addChoices(
{ name: 'Host', value: 'host' },
{ name: 'Gang', value: 'gang' },
{ name: 'Corporation', value: 'corporation' },
)
)
]
.map(command => command.toJSON());
@ -17,6 +27,10 @@ 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);
rest.put(Routes.applicationCommands(clientId), { body: [] })
.then((data) => console.log(`Removed all global commands`))
.catch(console.error);
rest.put(Routes.applicationCommands(clientId), { body: commands })
.then((data) => console.log(`Added ${data.length} commands to global`))
.catch(console.error);