Improve typing.
All checks were successful
Build and Publish Docker Image / build_and_push (push) Successful in 42s

This commit is contained in:
2024-09-16 14:13:37 +00:00
parent 73d06b2a54
commit 3a9fc1897a
8 changed files with 125 additions and 68 deletions

58
src/utils/commands.ts Normal file
View File

@@ -0,0 +1,58 @@
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 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(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,
});
}