···44<br>
5566## 🚀 Deployment
77+78Deploying this project is extremely simple. First, clone the repository:
89910```sh
···2425```
25262627## 🎨 Credits
2828+2729Certain features of this bot were the result
2830of conversations with:
2931
···11import { Events, MessageFlags, type Interaction } from "discord.js";
22import {
33- ChatInputCommandHandler,
44- ButtonHandler,
55- type VoidyClient,
66- type Event
33+ ChatInputCommandHandler,
44+ ButtonHandler,
55+ type VoidyClient,
66+ type Event,
77} from "@voidy/framework";
8899export default {
1010- id: "interactionCreate",
1111- name: Events.InteractionCreate,
1212- execute: async (client: VoidyClient, interaction: Interaction) => {
1313- if (interaction.isChatInputCommand() && interaction.isCommand()) {
1414- // Set the top-level command name
1515- let commandId = interaction.commandName;
1010+ id: "interactionCreate",
1111+ name: Events.InteractionCreate,
1212+ execute: async (client: VoidyClient, interaction: Interaction) => {
1313+ if (interaction.isChatInputCommand() && interaction.isCommand()) {
1414+ // Set the top-level command name
1515+ let commandId = interaction.commandName;
16161717- // Try to get a subgroup first
1818- const subgroup = interaction.options.getSubcommandGroup(false);
1919- if (subgroup) commandId += `.${subgroup}`;
1717+ // Try to get a subgroup first
1818+ const subgroup = interaction.options.getSubcommandGroup(false);
1919+ if (subgroup) commandId += `.${subgroup}`;
20202121- // Then subcommand (or subcommand in a group)
2222- const subcommand = interaction.options.getSubcommand(false);
2323- if (subcommand) commandId += `.${subcommand}`;
2121+ // Then subcommand (or subcommand in a group)
2222+ const subcommand = interaction.options.getSubcommand(false);
2323+ if (subcommand) commandId += `.${subcommand}`;
24242525- const command = client.commands.get(commandId);
2525+ const command = client.commands.get(commandId);
26262727- if (!command) return interaction.reply({
2828- content: `Sorry, but the command ${interaction.commandName} could not be located in my command cache >:3`,
2929- flags: [MessageFlags.Ephemeral]
3030- });
2727+ if (!command)
2828+ return interaction.reply({
2929+ content: `Sorry, but the command ${interaction.commandName} could not be located in my command cache >:3`,
3030+ flags: [MessageFlags.Ephemeral],
3131+ });
31323232- ChatInputCommandHandler.invoke(interaction, command, client);
3333- } else if (interaction.isButton()) {
3434- // Filter the client button cache to locate the invoked button
3535- const button = client.buttons.get(interaction.customId);
3333+ ChatInputCommandHandler.invoke(interaction, command, client);
3434+ } else if (interaction.isButton()) {
3535+ // Filter the client button cache to locate the invoked button
3636+ const button = client.buttons.get(interaction.customId);
36373737- if (!button) return interaction.reply({
3838- content: `Sorry, but the button ${interaction.customId} could not be located in my button cache >:3`,
3939- flags: [MessageFlags.Ephemeral]
4040- });
3838+ if (!button)
3939+ return interaction.reply({
4040+ content: `Sorry, but the button ${interaction.customId} could not be located in my button cache >:3`,
4141+ flags: [MessageFlags.Ephemeral],
4242+ });
41434242- ButtonHandler.invoke(interaction, button, client);
4343- } else {
4444- let dmChannel = interaction.user.dmChannel;
4444+ ButtonHandler.invoke(interaction, button, client);
4545+ } else {
4646+ let dmChannel = interaction.user.dmChannel;
45474646- // Attempt DM channel creation, if not found.
4747- if (!dmChannel) {
4848- dmChannel = await interaction.user.createDM();
4949- }
4848+ // Attempt DM channel creation, if not found.
4949+ if (!dmChannel) {
5050+ dmChannel = await interaction.user.createDM();
5151+ }
50525151- // If the DM channel is still not available, give up.
5252- if (!dmChannel || !dmChannel.isSendable()) return;
5353+ // If the DM channel is still not available, give up.
5454+ if (!dmChannel || !dmChannel.isSendable()) return;
53555454- dmChannel.send({
5555- content: `Sorry, but your last interaction wasn't successful and has been logged as an error case, for debugging purposes.\n\nIf you have any additional information to share with us, please communicate with the bot within this DM channel, and we will get in contact.\n\nThank you for understanding, and have a great day :3`,
5656- })
5757- }
5858- }
5959-} as Event
5656+ dmChannel.send({
5757+ content: `Sorry, but your last interaction wasn't successful and has been logged as an error case, for debugging purposes.\n\nIf you have any additional information to share with us, please communicate with the bot within this DM channel, and we will get in contact.\n\nThank you for understanding, and have a great day :3`,
5858+ });
5959+ }
6060+ },
6161+} as Event;
···33import type { VoidyClient } from "../core/VoidyClient";
4455export class ButtonHandler {
66- public static invoke(interaction: ButtonInteraction, payload: Button, client: VoidyClient): void {
77- payload.execute(interaction, client);
88- }
66+ public static invoke(interaction: ButtonInteraction, payload: Button, client: VoidyClient): void {
77+ payload.execute(interaction, client);
88+ }
99}
+7-3
packages/framework/src/handlers/CommandHandler.ts
···33import type { VoidyClient } from "../core/VoidyClient";
4455export class ChatInputCommandHandler {
66- public static invoke(interaction: ChatInputCommandInteraction, payload: Command, client: VoidyClient): void {
77- payload.execute(interaction, client);
88- }
66+ public static invoke(
77+ interaction: ChatInputCommandInteraction,
88+ payload: Command,
99+ client: VoidyClient,
1010+ ): void {
1111+ payload.execute(interaction, client);
1212+ }
913}
+5-5
packages/framework/src/loaders/ButtonLoader.ts
···88// ButtonLoader Implementation
99//===============================================
1010export class ButtonLoader extends Loader<Button> {
1111- public id = "button";
1212- public async validate(data: Partial<Button>) {
1313- if (!data.id || !data.execute) return null;
1414- return data as Button;
1515- }
1111+ public id = "button";
1212+ public async validate(data: Partial<Button>) {
1313+ if (!data.id || !data.execute) return null;
1414+ return data as Button;
1515+ }
1616}
+5-5
packages/framework/src/loaders/CommandLoader.ts
···88// CommandLoader Implementation
99//===============================================
1010export class CommandLoader extends Loader<Command> {
1111- public id = "command";
1212- public async validate(data: Partial<Command>) {
1313- if (!data.id || !data.data || !data.execute) return null;
1414- return data as Command;
1515- }
1111+ public id = "command";
1212+ public async validate(data: Partial<Command>) {
1313+ if (!data.id || !data.data || !data.execute) return null;
1414+ return data as Command;
1515+ }
1616}
+5-5
packages/framework/src/loaders/EventLoader.ts
···88// EventLoader Implemenation
99//===============================================
1010export class EventLoader extends Loader<Event> {
1111- public id = "event";
1212- public async validate(data: Partial<Event>) {
1313- if (!data.id || !data.name || !data.execute) return null;
1414- return data as Event;
1515- }
1111+ public id = "event";
1212+ public async validate(data: Partial<Event>) {
1313+ if (!data.id || !data.name || !data.execute) return null;
1414+ return data as Event;
1515+ }
1616}
+6-12
packages/framework/src/loaders/ModuleLoader.ts
···22// Imports
33//===============================================
44import type { Module } from "../core/types/Module";
55-import { Loader } from "../core/Loader"
55+import { Loader } from "../core/Loader";
6677//===============================================
88// ModuleLoader Implementation
99//===============================================
1010export class ModuleLoader extends Loader<Module> {
1111- public id = "module";
1212- public async validate(data: Partial<Module>) {
1313- if (
1414- !data.id ||
1515- !data.name ||
1616- !data.description ||
1717- !data.author ||
1818- !data.exports
1919- ) return null;
1111+ public id = "module";
1212+ public async validate(data: Partial<Module>) {
1313+ if (!data.id || !data.name || !data.description || !data.author || !data.exports) return null;
20142121- return data as Module;
2222- }
1515+ return data as Module;
1616+ }
2317}