From ed482c970716bdc62e1586d5203022d5835864e3 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 28 Oct 2019 19:54:36 -0400 Subject: [PATCH] re-add handleError func --- src/class/Util.ts | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index 2a833ab..e81e5b4 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -45,29 +45,31 @@ export default class Util { } public async handleError(error: Error, message?: Message, command?: Command): Promise { - this.client.signale.error(error); - /* - const info = { content: `\`\`\`js\n${error.stack}\n\`\`\``, embed: null }; - if (message) { - const embed = new RichEmbed(); - embed.setColor('FF0000'); - embed.setAuthor(`Error caused by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL); - embed.setTitle('Message content'); - embed.setDescription(message.content); - embed.addField('User', `${message.author.mention} (\`${message.author.id}\`)`, true); - embed.addField('Channel', message.channel.mention, true); - let guild: string; - if (message.channel instanceof PrivateChannel) guild = '@me'; - else guild = message.channel.guild.id; - embed.addField('Message link', `[Click here](https://discordapp.com/channels/${guild}/${message.channel.id}/${message.id})`, true); - embed.setTimestamp(new Date(message.timestamp)); - info.embed = embed; + try { + this.client.signale.error(error); + const info = { content: `\`\`\`js\n${error.stack}\n\`\`\``, embed: null }; + if (message) { + const embed = new RichEmbed(); + embed.setColor('FF0000'); + embed.setAuthor(`Error caused by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL); + embed.setTitle('Message content'); + embed.setDescription(message.content); + embed.addField('User', `${message.author.mention} (\`${message.author.id}\`)`, true); + embed.addField('Channel', message.channel.mention, true); + let guild: string; + if (message.channel instanceof PrivateChannel) guild = '@me'; + else guild = message.channel.guild.id; + embed.addField('Message link', `[Click here](https://discordapp.com/channels/${guild}/${message.channel.id}/${message.id})`, true); + embed.setTimestamp(new Date(message.timestamp)); + info.embed = embed; + } + await this.client.createMessage('595788220764127272', info); + if (message) this.client.createMessage('595788220764127272', 'Message content for above error'); + if (command) this.client.commands.get(command.name).enabled = false; + if (message) message.channel.createMessage(`***${this.client.stores.emojis.error} An unexpected error has occured - please contact a member of the Engineering Team.${command ? ' This command has been disabled.' : ''}***`); + } catch (err) { + this.client.signale.error(err); } - await this.client.createMessage('595788220764127272', info); - if (message) this.client.createMessage('595788220764127272', 'Message content for above error'); - if (command) this.client.commands.get(command.name).enabled = false; - if (message) message.channel.createMessage(`***${this.client.stores.emojis.error} An unexpected error has occured - please contact a member of the Engineering Team.${command ? ' This command has been disabled.' : ''}***`); - */ } public splitFields(fields: {name: string, value: string, inline?: boolean}[]): {name: string, value: string, inline?: boolean}[][] {