···11+import type { VoidyClient } from "./VoidyClient";
22+33+export class Logger {
44+ private logChannelId?: string;
55+66+ constructor(private client: VoidyClient) {}
77+88+ public async send(message: string) {
99+ if (!this.logChannelId) return;
1010+1111+ try {
1212+ const loggingChannel = this.client.channels.cache.get(this.logChannelId);
1313+ if (loggingChannel && loggingChannel.isSendable()) {
1414+ await loggingChannel.send(message);
1515+ }
1616+ } catch {}
1717+1818+ console.log(message);
1919+ }
2020+2121+ public setChannelId(id: string) {
2222+ this.logChannelId = id;
2323+ }
2424+}
+22-1
packages/framework/src/core/VoidyClient.ts
···1010 Events,
1111} from "discord.js";
1212import { ModuleManager, type CacheMap } from "./ModuleManager";
1313+import { Logger } from "./Logger";
1314import type { Command } from "./types/Command";
1415import type { Button } from "./types/Button";
1516import type { Event } from "./types/Event";
16171718//===============================================
1919+// ClientOptions Override
2020+//===============================================
2121+export interface VoidyClientOptions extends ClientOptions {
2222+ developers?: string[]; // List of developer user ids
2323+ logChannelId?: string; // ID of the channel to log events to
2424+}
2525+2626+//===============================================
1827// VoidyClient Implementation
1928//===============================================
2029export class VoidyClient extends Client {
2130 public moduleManager = new ModuleManager();
3131+ public developers: string[] = [];
3232+ public logger: Logger = new Logger(this);
22332323- public constructor(options: ClientOptions) {
3434+ public constructor(options: VoidyClientOptions) {
2435 super(options);
3636+3737+ // Set developers, if provided.
3838+ if (options.developers) {
3939+ this.developers = options.developers;
4040+ }
4141+4242+ // Inject channel ID into logger, if provided.
4343+ if (options.logChannelId) {
4444+ this.logger.setChannelId(options.logChannelId);
4545+ }
2546 }
26472748 /**
···11import type { ButtonInteraction } from "discord.js";
22-import type { Button } from "../loaders/ButtonLoader";
22+import type { Button } from "../core/types/Button";
33import type { VoidyClient } from "../core/VoidyClient";
4455export class ButtonHandler {
+13-4
packages/framework/src/handlers/CommandHandler.ts
···11-import type { ChatInputCommandInteraction } from "discord.js";
22-import type { Command } from "../loaders/CommandLoader";
11+import { MessageFlags, type ChatInputCommandInteraction } from "discord.js";
22+import type { Command } from "../core/types/Command";
33import type { VoidyClient } from "../core/VoidyClient";
4455export class ChatInputCommandHandler {
66- public static invoke(
66+ public static async invoke(
77 interaction: ChatInputCommandInteraction,
88 payload: Command,
99 client: VoidyClient,
1010- ): void {
1010+ ): Promise<void> {
1111+ if (!client.developers.includes(interaction.user.id)) {
1212+ await interaction.reply({
1313+ content: "You are not authorized to use this command.",
1414+ flags: [MessageFlags.Ephemeral]
1515+ });
1616+1717+ return;
1818+ }
1919+1120 payload.execute(interaction, client);
1221 }
1322}