UNPKG

discord-commands-sync

Version:

A CLI tool to manage discord application commands

20 lines 1.06 kB
import ora from 'ora'; import pc from 'picocolors'; import { Routes, ApplicationCommandType } from 'discord-api-types/v10'; export async function fetchGuildApplicationCommands(rest, commandType, clientId, guildId) { const spinner = ora('Fetching guild application commands').start(); const commands = (await rest.get(Routes.applicationGuildCommands(clientId, guildId))); spinner.succeed(pc.bold(pc.green('Guild application commands fetched'))); if (commands.length === 0) { spinner.fail(pc.bold(pc.red('No global application commands found, exiting!'))); process.exit(0); } if (commandType === ApplicationCommandType.ChatInput) { return commands.filter((command) => command.type === ApplicationCommandType.ChatInput); } if (commandType === ApplicationCommandType.Message) { return commands.filter((command) => command.type === ApplicationCommandType.Message); } return commands.filter((command) => command.type === ApplicationCommandType.User); } //# sourceMappingURL=guild-commands.js.map