join the community
https://ultirequiem.com/discord
This is the first Discord bot I'm doing, I ever done one using the now dead discord.py while learning to code, so I'm just learning on the fly, feel free to make PR or Issues!
Things I learned while making this bot 📖
People are doing very strange things to handle the commands, here is a simpler way 👇
import type { CommandInteraction } from "discord.js";
import { info, ping, rules } from "./myCommands";
export type command = (interaction: CommandInteraction) => Promise<void>;
export type commandHandler = { [key: string]: command };
export const commands: commandHandler = { ping, rules, info };
Usage 👇
client.on("interactionCreate", async (interaction) => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
await commands[commandName](interaction);
});
Completely type-safe!
The example in the docs wouldn't work on TypeScript, and would be tricky to make it work using native ESM!
GNU General Public License v3.0.