mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 08:13:09 +02:00
Respond with error messages
instead of giving the user no information.
This commit is contained in:
parent
76ed77fe0c
commit
b61b3dd2b1
@ -68,9 +68,6 @@ commands:
|
|||||||
reason:
|
reason:
|
||||||
description: The reason for closing the ticket(s)
|
description: The reason for closing the ticket(s)
|
||||||
name: reason
|
name: reason
|
||||||
ticket:
|
|
||||||
description: The ticket to close
|
|
||||||
name: ticket
|
|
||||||
force-close:
|
force-close:
|
||||||
confirm_multiple:
|
confirm_multiple:
|
||||||
description: >
|
description: >
|
||||||
@ -120,7 +117,7 @@ commands:
|
|||||||
settings: Bot settings
|
settings: Bot settings
|
||||||
title: Help
|
title: Help
|
||||||
move:
|
move:
|
||||||
description: move a ticket to another category
|
description: Move a ticket to another category
|
||||||
name: move
|
name: move
|
||||||
options:
|
options:
|
||||||
category:
|
category:
|
||||||
@ -220,7 +217,8 @@ commands:
|
|||||||
member:
|
member:
|
||||||
description: The member to transfer ownership to
|
description: The member to transfer ownership to
|
||||||
name: member
|
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:
|
user:
|
||||||
create:
|
create:
|
||||||
name: Create a ticket for user
|
name: Create a ticket for user
|
||||||
@ -289,8 +287,9 @@ misc:
|
|||||||
error:
|
error:
|
||||||
description: Sorry, an unexpected error occurred.
|
description: Sorry, an unexpected error occurred.
|
||||||
fields:
|
fields:
|
||||||
|
code: Error code
|
||||||
identifier: Identifier
|
identifier: Identifier
|
||||||
title: ⚠️ Something's wrong
|
title: ⚠️ Something went wrong
|
||||||
expired:
|
expired:
|
||||||
description: You didn't respond in time. Please try again.
|
description: You didn't respond in time. Please try again.
|
||||||
title: ⏰ Expired
|
title: ⏰ Expired
|
||||||
@ -334,7 +333,6 @@ ticket:
|
|||||||
answers:
|
answers:
|
||||||
no_value: "*No response*"
|
no_value: "*No response*"
|
||||||
claimed: 🙌 {user} has claimed this ticket.
|
claimed: 🙌 {user} has claimed this ticket.
|
||||||
released: ♻️ {user} has released this ticket.
|
|
||||||
created:
|
created:
|
||||||
description: "Your ticket channel has been created: {channel}."
|
description: "Your ticket channel has been created: {channel}."
|
||||||
title: ✅ Ticket created
|
title: ✅ Ticket created
|
||||||
@ -357,3 +355,4 @@ ticket:
|
|||||||
number: Number
|
number: Number
|
||||||
topic: Topic
|
topic: Topic
|
||||||
title: ℹ️ Reference
|
title: ℹ️ Reference
|
||||||
|
released: ♻️ {user} has released this ticket.
|
||||||
|
57
src/listeners/buttons/error.js
Normal file
57
src/listeners/buttons/error.js
Normal file
@ -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));
|
||||||
|
}
|
||||||
|
};
|
@ -1,4 +1,8 @@
|
|||||||
const { Listener } = require('@eartharoid/dbf');
|
const { Listener } = require('@eartharoid/dbf');
|
||||||
|
const {
|
||||||
|
EmbedBuilder,
|
||||||
|
inlineCode,
|
||||||
|
} = require('discord.js');
|
||||||
|
|
||||||
module.exports = class extends Listener {
|
module.exports = class extends Listener {
|
||||||
constructor(client, options) {
|
constructor(client, options) {
|
||||||
@ -9,11 +13,45 @@ module.exports = class extends Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
run({
|
async run({
|
||||||
command,
|
command,
|
||||||
error,
|
error,
|
||||||
|
interaction,
|
||||||
}) {
|
}) {
|
||||||
|
const ref = require('crypto').randomUUID();
|
||||||
|
this.client.log.error.commands(ref);
|
||||||
this.client.log.error.commands(`"${command.name}" command execution error:`, error);
|
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));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user