A powerful and extendable Discord bot, with it's own module system :3
thevoid.cafe/projects/voidy
1import type {
2 ChatInputCommandInteraction,
3 SlashCommandBuilder,
4 SlashCommandSubcommandBuilder,
5 SlashCommandOptionsOnlyBuilder,
6} from "discord.js";
7import type { Context } from "../core/context";
8import type { Middleware } from "../types/Middleware";
9
10export interface CommandOptions {
11 id: string;
12 data: SlashCommandBuilder | SlashCommandSubcommandBuilder | SlashCommandOptionsOnlyBuilder;
13 use?: Middleware<ChatInputCommandInteraction>[];
14 execute: (ctx: Context<ChatInputCommandInteraction>) => Promise<void>;
15}
16
17export class Command {
18 readonly type = "command" as const;
19 readonly id: string;
20 readonly data: SlashCommandBuilder | SlashCommandSubcommandBuilder | SlashCommandOptionsOnlyBuilder;
21 readonly use?: Middleware<ChatInputCommandInteraction>[];
22 readonly execute: (ctx: Context<ChatInputCommandInteraction>) => Promise<void>;
23
24 constructor(options: CommandOptions) {
25 this.id = options.id;
26 this.data = options.data;
27 this.use = options.use;
28 this.execute = options.execute;
29 }
30}