discord-commands-sync
Version:
A CLI tool to manage discord application commands
20 lines • 1.04 kB
JavaScript
import ora from 'ora';
import pc from 'picocolors';
import { Routes, ApplicationCommandType } from 'discord-api-types/v10';
export async function fetchGlobalApplicationCommands(rest, commandType, clientId) {
const spinner = ora('Fetching global application commands').start();
const commands = (await rest.get(Routes.applicationCommands(clientId)));
spinner.succeed(pc.bold(pc.green('Global 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=global-command.js.map