diff --git a/src/client/events.ts b/src/client/events.ts index 53d7448..417c24d 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 async onMessage(message: Message): Promise { + public onMessage(message: Message): IEventResponse { 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 = await this._util.loadCommand(name, args, message); + const res = this._util.loadCommand(name, args, message); if (!res.valid) { return { diff --git a/src/client/util.ts b/src/client/util.ts index 9046a8b..428976e 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 async loadCommand(name: string, args: string[], message: Message): Promise { + public loadCommand(name: string, args: string[], message: Message): IUtilResponse { if (!message.member) return { valid: false, message: "Member is not part of message", diff --git a/tests/client/util.test.ts b/tests/client/util.test.ts index c79e15d..fe046e2 100644 --- a/tests/client/util.test.ts +++ b/tests/client/util.test.ts @@ -10,7 +10,7 @@ beforeEach(() => { }); describe('LoadCommand', () => { - test('Given Successful Exection, Expect Successful Result', async () => { + test('Given Successful Exection, Expect Successful Result', () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -34,12 +34,12 @@ describe('LoadCommand', () => { const util = new Util(); - const result = await util.loadCommand("normal", [ "first" ], message); + const result = util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeTruthy(); }); - test('Given Member Is Null, Expect Failed Result', async () => { + test('Given Member Is Null, Expect Failed Result', () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -56,13 +56,13 @@ describe('LoadCommand', () => { const util = new Util(); - const result = await util.loadCommand("normal", [ "first" ], message); + const result = util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Member is not part of message"); }); - test('Given Folder Does Not Exist, Expect Failed Result', async () => { + test('Given Folder Does Not Exist, Expect Failed Result', () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -86,13 +86,13 @@ describe('LoadCommand', () => { const util = new Util(); - const result = await util.loadCommand("normal", [ "first" ], message); + const result = util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Command folder does not exist"); }); - test('Given File Does Not Exist, Expect Failed Result', async () => { + test('Given File Does Not Exist, Expect Failed Result', () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -117,13 +117,13 @@ describe('LoadCommand', () => { const util = new Util(); - const result = await util.loadCommand("normal", [ "first" ], message); + const result = util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("File does not exist"); }); - test('Given User Does Have Role, Expect Successful Result', async () => { + test('Given User Does Have Role, Expect Successful Result', () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -147,12 +147,12 @@ describe('LoadCommand', () => { const util = new Util(); - const result = await util.loadCommand("roles", [ "first" ], message); + const result = util.loadCommand("roles", [ "first" ], message); expect(result.valid).toBeTruthy(); }); - test('Given User Does Not Have Role, Expect Failed Result', async () => { + test('Given User Does Not Have Role, Expect Failed Result', () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -176,13 +176,13 @@ describe('LoadCommand', () => { const util = new Util(); - const result = await util.loadCommand("roles", [ "first" ], message); + const result = util.loadCommand("roles", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("You require the `Moderator` role to run this command"); }); - test('Given Command Category Is Null, Expect Successful Result', async () => { + test('Given Command Category Is Null, Expect Successful Result', () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -206,12 +206,12 @@ describe('LoadCommand', () => { const util = new Util(); - const result = await util.loadCommand("noCategory", [ "first" ], message); + const result = util.loadCommand("noCategory", [ "first" ], message); expect(result.valid).toBeTruthy(); }); - test('Given command is set to disabled, Expect command to not fire', async () => { + test('Given command is set to disabled, Expect command to not fire', () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -239,14 +239,14 @@ describe('LoadCommand', () => { const util = new Util(); - const result = await util.loadCommand("normal", [ "first" ], message); + const result = util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Command is disabled"); expect(messageReply).toBeCalledWith("disabled"); }); - test('Given command COMMANDS_DISABLED_MESSAGE is empty, Expect default message sent', async () => { + test('Given command COMMANDS_DISABLED_MESSAGE is empty, Expect default message sent', () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -273,14 +273,14 @@ describe('LoadCommand', () => { const util = new Util(); - const result = await util.loadCommand("normal", [ "first" ], message); + const result = util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Command is disabled"); expect(messageReply).toBeCalledWith("This command is disabled."); }); - test('Given a different command is disabled, Expect command to still fire', async () => { + test('Given a different command is disabled, Expect command to still fire', () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -305,12 +305,12 @@ describe('LoadCommand', () => { const util = new Util(); - const result = await util.loadCommand("normal", [ "first" ], message); + const result = util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeTruthy(); }); - test('Given a different command is disabled with this one, Expect command to not fire', async () => { + test('Given a different command is disabled with this one, Expect command to not fire', () => { process.env = { BOT_TOKEN: 'TOKEN', BOT_PREFIX: '!', @@ -335,7 +335,7 @@ describe('LoadCommand', () => { const util = new Util(); - const result = await util.loadCommand("normal", [ "first" ], message); + const result = util.loadCommand("normal", [ "first" ], message); expect(result.valid).toBeFalsy(); expect(result.message).toBe("Command is disabled");