VBC-52 Use export default rather than class of the same name #53

Merged
Vylpes merged 4 commits from feature/VBC-52 into develop 2021-09-29 17:53:21 +01:00
3 changed files with 25 additions and 25 deletions
Showing only changes of commit 5ce0960606 - Show all commits

View file

@ -20,7 +20,7 @@ export class Events {
// Emit when a message is sent
// Used to check for commands
public async onMessage(message: Message): Promise<IEventResponse> {
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 {

View file

@ -16,7 +16,7 @@ export interface IUtilResponse extends IBaseResponse {
// Util Class
export class Util {
public async loadCommand(name: string, args: string[], message: Message): Promise<IUtilResponse> {
public loadCommand(name: string, args: string[], message: Message): IUtilResponse {
if (!message.member) return {
valid: false,
message: "Member is not part of message",

View file

@ -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");