61 lines
2.2 KiB
TypeScript
61 lines
2.2 KiB
TypeScript
import { Collection, REST, Routes } from 'discord.js';
|
|
import * as birthday from '../commands/birthday';
|
|
import * as corrupt from '../commands/corrupt';
|
|
import * as countdown from '../commands/countdown';
|
|
import * as eyecandy from '../commands/eyecandy';
|
|
import * as game from '../commands/game';
|
|
import * as gerard from '../commands/gerard';
|
|
import * as image from '../commands/image';
|
|
import * as imdb from '../commands/imdb';
|
|
import * as kanye from '../commands/kanye';
|
|
import * as magicEightBall from '../commands/magic8Ball';
|
|
import * as payday from '../commands/payday';
|
|
import * as plant from '../commands/plant';
|
|
import * as reminder from '../commands/reminder';
|
|
import * as servertime from '../commands/servertime';
|
|
import * as taylor from '../commands/taylor';
|
|
import * as twentyTwenty from '../commands/twentyTwenty';
|
|
import config from '../config';
|
|
import { Command } from './types';
|
|
|
|
/**
|
|
* Get all commands as a collection.
|
|
* @returns A collection of commands.
|
|
*/
|
|
export function getCommands(): Collection<string, Command> {
|
|
const commands = new Collection<string, Command>();
|
|
|
|
commands.set(birthday.data.name, birthday);
|
|
commands.set(corrupt.data.name, corrupt);
|
|
commands.set(countdown.data.name, countdown);
|
|
commands.set(eyecandy.data.name, eyecandy);
|
|
commands.set(game.data.name, game);
|
|
commands.set(gerard.data.name, gerard);
|
|
commands.set(image.data.name, image);
|
|
commands.set(imdb.data.name, imdb);
|
|
commands.set(kanye.data.name, kanye);
|
|
commands.set(magicEightBall.data.name, magicEightBall);
|
|
commands.set(payday.data.name, payday);
|
|
commands.set(plant.data.name, plant);
|
|
commands.set(reminder.data.name, reminder);
|
|
commands.set(servertime.data.name, servertime);
|
|
commands.set(taylor.data.name, taylor);
|
|
commands.set(twentyTwenty.data.name, twentyTwenty);
|
|
|
|
return commands;
|
|
}
|
|
|
|
/**
|
|
* Register all slash commands globally across all Guilds.
|
|
* @param commands A collection of commands to register.
|
|
*/
|
|
export async function registerSlashCommands(
|
|
commands: Collection<string, Command>
|
|
) {
|
|
const commandData = commands.map((command) => command.data.toJSON());
|
|
const rest = new REST({ version: '10' }).setToken(config.discordApiKey);
|
|
await rest.put(Routes.applicationCommands(config.discordApplicationId), {
|
|
body: commandData,
|
|
});
|
|
}
|