mirror of
https://github.com/pacnpal/markov-discord.git
synced 2025-12-20 11:01:04 -05:00
Initial rough working draft of v3
This commit is contained in:
22
src/deploy-commands.ts
Normal file
22
src/deploy-commands.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||
import { REST } from '@discordjs/rest';
|
||||
import { Routes } from 'discord-api-types/v9';
|
||||
import { config } from './config';
|
||||
import { packageJson } from './util';
|
||||
|
||||
const helpSlashCommand = new SlashCommandBuilder()
|
||||
.setName('help')
|
||||
.setDescription(`How to use ${packageJson().name}`);
|
||||
|
||||
const commands = [helpSlashCommand.toJSON()];
|
||||
|
||||
export async function deployCommands(clientId: string) {
|
||||
const rest = new REST({ version: '9' }).setToken(config.token);
|
||||
if (config.devGuildId) {
|
||||
await rest.put(Routes.applicationGuildCommands(clientId, config.devGuildId), {
|
||||
body: commands,
|
||||
});
|
||||
} else {
|
||||
await rest.put(Routes.applicationCommands(clientId), { body: commands });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user