···01import { Handler } from "../core/Handler";
2import type { Command } from "../loaders/CommandLoader";
034export class CommandHandler extends Handler<Command> {
5- public invoke(data: Command): void {
0000006 console.log(data);
0007 }
8}
···1+import type { ChatInputCommandInteraction } from "discord.js";
2import { Handler } from "../core/Handler";
3import type { Command } from "../loaders/CommandLoader";
4+import type { VoidyClient } from "../core/VoidyClient";
56export class CommandHandler extends Handler<Command> {
7+ public constructor(
8+ client: VoidyClient
9+ ) {
10+ super(client);
11+ }
12+13+ public invoke(data: ChatInputCommandInteraction): void {
14 console.log(data);
15+ // @Todo: implement invoke method, which fetches command information from registries, based on the command name
16+ //
17+ // @Todo: consider whether we actually need handlers as separate classes, or if we can just give the client a handle method.
18 }
19}
-4
src/index.ts
···1import { GatewayIntentBits } from "discord.js"
2import { VoidyClient } from "./core/VoidyClient"
3-// import { EventLoader } from "./loaders/EventLoader";
4-// import { join } from "node:path";
56// Client initialization with intents and stuff...
7const client = new VoidyClient({
8 intents: [GatewayIntentBits.Guilds],
9})
10-11-1213// Token validation and client start
14if (!Bun.env.BOT_TOKEN) throw new Error("[Voidy] Missing bot token");
···1import { GatewayIntentBits } from "discord.js"
2import { VoidyClient } from "./core/VoidyClient"
0034// Client initialization with intents and stuff...
5const client = new VoidyClient({
6 intents: [GatewayIntentBits.Guilds],
7})
0089// Token validation and client start
10if (!Bun.env.BOT_TOKEN) throw new Error("[Voidy] Missing bot token");
+3
src/modules/core/events/interactionCreate.ts
···1import { Events, type Interaction } from "discord.js";
2import type { Event } from "../../../loaders/EventLoader";
3import type { VoidyClient } from "../../../core/VoidyClient";
045export default {
6 name: Events.InteractionCreate,
···8 if (!interaction.isChatInputCommand() || !interaction.isCommand()) return null;
910 console.log(interaction.commandName);
0011 }
12} as Event
···1import { Events, type Interaction } from "discord.js";
2import type { Event } from "../../../loaders/EventLoader";
3import type { VoidyClient } from "../../../core/VoidyClient";
4+import { CommandHandler } from "../../../handlers/CommandHandler";
56export default {
7 name: Events.InteractionCreate,
···9 if (!interaction.isChatInputCommand() || !interaction.isCommand()) return null;
1011 console.log(interaction.commandName);
12+13+14 }
15} as Event