From a0294ae44b23ce439fd57935fb71c8f04e6ac789 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 15 Oct 2019 15:42:42 +0100 Subject: [PATCH] Utils fix --- src/Util.ts | 6 +++--- src/events/messageCreate.ts | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Util.ts b/src/Util.ts index 600f4c3..f1e9ece 100644 --- a/src/Util.ts +++ b/src/Util.ts @@ -29,9 +29,9 @@ export default class Util { this.client.guilds.get('446067825673633794').channels.get('595788220764127272').createMessage(`\`\`\`ts\n${error.stack}\`\`\``); } - public resolveCommand(client: Client, command: string): Command { - if (client.commands.has(command)) return client.commands.get(command); - for (const cmd of client.commands.values()) { + public resolveCommand(command: string): Command { + if (this.client.commands.has(command)) return this.client.commands.get(command); + for (const cmd of this.client.commands.values()) { if (!cmd.aliases) continue; for (const alias of cmd.aliases) { if (command === alias.toLowerCase()) return cmd; diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 79e4237..190f762 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -10,11 +10,12 @@ export default class { constructor(client: Client) { this.client = client; } + util: Util = new Util(this.client) async run(message: Message) { const noPrefix: string[] = message.content.slice(prefix.length).trim().split(/ +/g); const command: string = noPrefix[0].toLowerCase(); - const resolved: Command = new Util().resolveCommand(this.client, command); + const resolved: Command = this.util.resolveCommand(command); if (!resolved) return; if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return; const hasUserPerms: boolean = resolved.permissions.users.includes(message.author.id);