From 00a057792b3bf449c0ceb235046e3b7e881541ee Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sun, 26 Sep 2021 14:12:21 +0100 Subject: [PATCH] Make command loader use the default class --- src/client/events.ts | 4 ++-- src/client/util.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client/events.ts b/src/client/events.ts index 417c24d..53d7448 100644 --- a/src/client/events.ts +++ b/src/client/events.ts @@ -20,7 +20,7 @@ export class Events { // Emit when a message is sent // Used to check for commands - public onMessage(message: Message): IEventResponse { + public async onMessage(message: Message): Promise { if (!message.guild) return { valid: false, message: "Message was not sent in a guild, ignoring.", @@ -42,7 +42,7 @@ export class Events { message: "Command name was not found", }; - const res = this._util.loadCommand(name, args, message); + const res = await this._util.loadCommand(name, args, message); if (!res.valid) { return { diff --git a/src/client/util.ts b/src/client/util.ts index bc675e0..9046a8b 100644 --- a/src/client/util.ts +++ b/src/client/util.ts @@ -16,7 +16,7 @@ export interface IUtilResponse extends IBaseResponse { // Util Class export class Util { - public loadCommand(name: string, args: string[], message: Message): IUtilResponse { + public async loadCommand(name: string, args: string[], message: Message): Promise { if (!message.member) return { valid: false, message: "Member is not part of message", @@ -37,9 +37,9 @@ export class Util { if (existsSync(`${process.cwd()}/${folder}/`)) { if (existsSync(`${process.cwd()}/${folder}/${name}.ts`)) { - const commandFile = require(`${process.cwd()}/${folder}/${name}.ts`); - const command = new commandFile[name]() as Command; - + const commandFile = require(`${process.cwd()}/${folder}/${name}.ts`).default; + const command = new commandFile() as Command; + const requiredRoles = command._roles; if (!command._category) command._category = "none";