wrap messageCreate event in try/catch block

merge-requests/1/merge
Matthew 2020-04-14 21:33:58 -04:00
parent b194c7e097
commit b5be5c7d28
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 13 additions and 8 deletions

View File

@ -10,6 +10,7 @@ export default class {
} }
public async run(message: Message) { public async run(message: Message) {
try {
if (message.author.bot) return; if (message.author.bot) return;
if (message.content.indexOf(this.client.config.prefix) !== 0) return; if (message.content.indexOf(this.client.config.prefix) !== 0) return;
const noPrefix: string[] = message.content.slice(this.client.config.prefix.length).trim().split(/ +/g); const noPrefix: string[] = message.content.slice(this.client.config.prefix.length).trim().split(/ +/g);
@ -17,6 +18,10 @@ export default class {
if (!resolved) return; if (!resolved) return;
if (resolved.cmd.guildOnly && !(message.channel instanceof TextChannel)) return; if (resolved.cmd.guildOnly && !(message.channel instanceof TextChannel)) return;
if (!resolved.cmd.enabled) { message.channel.createMessage(`***${this.client.util.emojis.ERROR} This command has been disabled***`); return; } 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); await resolved.cmd.run(message, resolved.args);
} catch (err) {
this.client.util.handleError(err, message);
}
} }
} }