forked from engineering/cloudservices
use util binded to client on messageCreate
parent
be6866fbd3
commit
2c8dc89a42
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue