aboutsummaryrefslogtreecommitdiff
path: root/src/listeners/commands
diff options
context:
space:
mode:
authorTymanWasTaken <tyman@tyman.tech>2021-05-17 14:06:24 -0400
committerTymanWasTaken <tyman@tyman.tech>2021-05-17 14:06:24 -0400
commit9aee8c80067530b178612f1261c38b83683f266d (patch)
tree2ac52f719bdd77ef0265da2de02336f0759deaba /src/listeners/commands
parent4d63c4af57a7391dd61106b79874b8e83c14971a (diff)
downloadtanzanite-9aee8c80067530b178612f1261c38b83683f266d.tar.gz
tanzanite-9aee8c80067530b178612f1261c38b83683f266d.tar.bz2
tanzanite-9aee8c80067530b178612f1261c38b83683f266d.zip
probably works idk what all I did
Diffstat (limited to 'src/listeners/commands')
-rw-r--r--src/listeners/commands/slashError.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/listeners/commands/slashError.ts b/src/listeners/commands/slashError.ts
new file mode 100644
index 0000000..3b174a3
--- /dev/null
+++ b/src/listeners/commands/slashError.ts
@@ -0,0 +1,48 @@
+import { BotCommand } from '../../lib/extensions/BotCommand';
+import { BotListener } from '../../lib/extensions/BotListener';
+import { stripIndents } from 'common-tags';
+import { MessageEmbed } from 'discord.js';
+import { TextChannel } from 'discord.js';
+import { CommandInteraction } from 'discord.js';
+
+export default class CommandErrorListener extends BotListener {
+ constructor() {
+ super('slashError', {
+ emitter: 'commandHandler',
+ event: 'slashError'
+ });
+ }
+ async exec(
+ error: Error,
+ message: CommandInteraction,
+ command: BotCommand
+ ): Promise<void> {
+ const errorNumber = Math.floor(Math.random() * 6969696969) + 69; // hehe funy numbers
+ const errorDevEmbed = this.client.util
+ .createEmbed(this.client.util.colors.error)
+ .setTitle(`Slash Error # \`${errorNumber}\`: An error occurred`)
+ .setDescription(
+ stripIndents`**User:** <@${message.user.id}> (${message.user.tag})
+ **Slash Command:** ${command}
+ **Channel:** <#${message.channelID}> (${message.channelID})
+ **Message:** [link](https://discord.com/${message.guildID}/${message.channelID}/${message.id})`
+ )
+ .addField('Error', `${await this.client.util.haste(error.stack)}`);
+ let errorUserEmbed: MessageEmbed;
+ if (command) {
+ errorUserEmbed = this.client.util
+ .createEmbed(this.client.util.colors.error)
+ .setTitle('An error occurred')
+ .setDescription(
+ stripIndents`Whoops! It appears like something broke.
+ The developers have been notified of this. If you contact them, give them code \`${errorNumber}\`.
+ `
+ );
+ }
+ const channel = (await this.client.channels.fetch(
+ this.client.config.channels.log
+ )) as TextChannel;
+ await channel.send(errorDevEmbed);
+ if (errorUserEmbed) await message.reply(errorUserEmbed);
+ }
+}