use util binded to client on messageCreate

merge-requests/1/merge
Matthew 2019-10-26 13:06:54 -04:00
parent be6866fbd3
commit 2c8dc89a42
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 5 additions and 7 deletions

View File

@ -1,23 +1,21 @@
import { Message, TextChannel } from 'eris'; import { Message, TextChannel } from 'eris';
import { Client, config, Util } from '..'; import { Client, config } from '..';
import Command from '../class/Command'; import Command from '../class/Command';
const { prefix } = config; const { prefix } = config;
export default class { export default class {
client: Client public client: Client
constructor(client: Client) { constructor(client: Client) {
this.client = client; this.client = client;
} }
util: Util = new Util(this.client) public async run(message: Message) {
async run(message: Message) {
try { try {
const noPrefix: string[] = message.content.slice(prefix.length).trim().split(/ +/g); const noPrefix: string[] = message.content.slice(prefix.length).trim().split(/ +/g);
const command: string = noPrefix[0].toLowerCase(); const command: string = noPrefix[0].toLowerCase();
const resolved: Command = this.util.resolveCommand(command); const resolved: Command = this.client.util.resolveCommand(command);
if (!resolved) return; if (!resolved) return;
if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return; if (resolved.guildOnly && !(message.channel instanceof TextChannel)) return;
const hasUserPerms: boolean = resolved.permissions.users.includes(message.author.id); const hasUserPerms: boolean = resolved.permissions.users.includes(message.author.id);
@ -32,7 +30,7 @@ export default class {
const args: string[] = noPrefix.slice(1); const args: string[] = noPrefix.slice(1);
resolved.run(message, args); resolved.run(message, args);
} catch (error) { } catch (error) {
this.util.handleError(error, message); this.client.util.handleError(error, message);
} }
} }
} }