wrap messageCreate event in try/catch block
parent
b194c7e097
commit
b5be5c7d28
|
@ -10,13 +10,18 @@ export default class {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async run(message: Message) {
|
public async run(message: Message) {
|
||||||
if (message.author.bot) return;
|
try {
|
||||||
if (message.content.indexOf(this.client.config.prefix) !== 0) return;
|
if (message.author.bot) return;
|
||||||
const noPrefix: string[] = message.content.slice(this.client.config.prefix.length).trim().split(/ +/g);
|
if (message.content.indexOf(this.client.config.prefix) !== 0) return;
|
||||||
const resolved = await this.client.util.resolveCommand(noPrefix);
|
const noPrefix: string[] = message.content.slice(this.client.config.prefix.length).trim().split(/ +/g);
|
||||||
if (!resolved) return;
|
const resolved = await this.client.util.resolveCommand(noPrefix);
|
||||||
if (resolved.cmd.guildOnly && !(message.channel instanceof TextChannel)) return;
|
if (!resolved) return;
|
||||||
if (!resolved.cmd.enabled) { message.channel.createMessage(`***${this.client.util.emojis.ERROR} This command has been disabled***`); return; }
|
if (resolved.cmd.guildOnly && !(message.channel instanceof TextChannel)) return;
|
||||||
await resolved.cmd.run(message, resolved.args);
|
if (!resolved.cmd.enabled) { message.channel.createMessage(`***${this.client.util.emojis.ERROR} This command has been disabled***`); return; }
|
||||||
|
this.client.util.signale.info(`User '${message.author.username}#${message.author.discriminator}' ran command '${resolved.cmd.name}' in '${message.channel.id}'.`);
|
||||||
|
await resolved.cmd.run(message, resolved.args);
|
||||||
|
} catch (err) {
|
||||||
|
this.client.util.handleError(err, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue