diff --git a/src/i18n/en-GB.yml b/src/i18n/en-GB.yml index ccf46a6..da30ed4 100644 --- a/src/i18n/en-GB.yml +++ b/src/i18n/en-GB.yml @@ -68,9 +68,6 @@ commands: reason: description: The reason for closing the ticket(s) name: reason - ticket: - description: The ticket to close - name: ticket force-close: confirm_multiple: description: > @@ -120,7 +117,7 @@ commands: settings: Bot settings title: Help move: - description: move a ticket to another category + description: Move a ticket to another category name: move options: category: @@ -220,7 +217,8 @@ commands: member: description: The member to transfer ownership to name: member - transferred: 📨 {user} has transferred this ticket from {from} to {to}. + transferred: 📨 {user} has transferred this ticket to {to}. + transferred_from: 📨 {user} has transferred this ticket from {from} to {to}. user: create: name: Create a ticket for user @@ -289,8 +287,9 @@ misc: error: description: Sorry, an unexpected error occurred. fields: + code: Error code identifier: Identifier - title: ⚠ī¸ Something's wrong + title: ⚠ī¸ Something went wrong expired: description: You didn't respond in time. Please try again. title: ⏰ Expired @@ -334,7 +333,6 @@ ticket: answers: no_value: "*No response*" claimed: 🙌 {user} has claimed this ticket. - released: â™ģī¸ {user} has released this ticket. created: description: "Your ticket channel has been created: {channel}." title: ✅ Ticket created @@ -357,3 +355,4 @@ ticket: number: Number topic: Topic title: ℹī¸ Reference + released: â™ģī¸ {user} has released this ticket. diff --git a/src/listeners/buttons/error.js b/src/listeners/buttons/error.js new file mode 100644 index 0000000..ba3a2f8 --- /dev/null +++ b/src/listeners/buttons/error.js @@ -0,0 +1,57 @@ +const { Listener } = require('@eartharoid/dbf'); +const { + EmbedBuilder, + inlineCode, +} = require('discord.js'); + +module.exports = class extends Listener { + constructor(client, options) { + super(client, { + ...options, + emitter: client.buttons, + event: 'error', + }); + } + + async run({ + button, + error, + interaction, + }) { + const ref = require('crypto').randomUUID(); + this.client.log.error.buttons(ref); + this.client.log.error.buttons(`"${button.name}" button execution error:`, error); + let locale = null; + if (interaction.guild) { + locale = (await this.client.prisma.guild.findUnique({ + select: { locale: true }, + where: { id: interaction.guild.id }, + })).locale; + } + const getMessage = this.client.i18n.getLocale(locale); + const fields = [ + { + name: getMessage('misc.error.fields.identifier'), + value: inlineCode(ref), + }, + ]; + if (error.name) { + fields.unshift({ + name: getMessage('misc.error.fields.code'), + value: inlineCode(error.name), + }); + } + const data = { + components: [], + embeds: [ + new EmbedBuilder() + .setColor('Orange') + .setTitle(getMessage('misc.error.title')) + .setDescription(getMessage('misc.error.description')) + .addFields(fields), + ], + }; + + interaction.reply(data).catch(() => interaction.editReply(data)); + } +}; diff --git a/src/listeners/commands/error.js b/src/listeners/commands/error.js index 6383585..8e4edbc 100644 --- a/src/listeners/commands/error.js +++ b/src/listeners/commands/error.js @@ -1,4 +1,8 @@ const { Listener } = require('@eartharoid/dbf'); +const { + EmbedBuilder, + inlineCode, +} = require('discord.js'); module.exports = class extends Listener { constructor(client, options) { @@ -9,11 +13,45 @@ module.exports = class extends Listener { }); } - run({ + async run({ command, error, + interaction, }) { + const ref = require('crypto').randomUUID(); + this.client.log.error.commands(ref); this.client.log.error.commands(`"${command.name}" command execution error:`, error); - return true; + let locale = null; + if (interaction.guild) { + locale = (await this.client.prisma.guild.findUnique({ + select: { locale: true }, + where: { id: interaction.guild.id }, + })).locale; + } + const getMessage = this.client.i18n.getLocale(locale); + const fields = [ + { + name: getMessage('misc.error.fields.identifier'), + value: inlineCode(ref), + }, + ]; + if (error.name) { + fields.unshift({ + name: getMessage('misc.error.fields.code'), + value: inlineCode(error.name), + }); + } + const data = { + components: [], + embeds: [ + new EmbedBuilder() + .setColor('Orange') + .setTitle(getMessage('misc.error.title')) + .setDescription(getMessage('misc.error.description')) + .addFields(fields), + ], + }; + + interaction.reply(data).catch(() => interaction.editReply(data)); } };