diff options
Diffstat (limited to 'handler/errors.js')
-rw-r--r--[-rwxr-xr-x] | handler/errors.js | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/handler/errors.js b/handler/errors.js index 1bae519..c816369 100755..100644 --- a/handler/errors.js +++ b/handler/errors.js @@ -2,43 +2,47 @@ const fs = require('fs'); const { MessageActionRow, MessageButton, MessageSelectMenu, MessageEmbed } = require('discord.js');
module.exports = async (interaction, e) => {
+ console.error(e);
+ fs.writeFileSync("./reports/Telemetry-Crash-" + (new Date().toISOString().replace(/[^a-zA-Z0-9]/gm, "-")) + ".txt", "-------------------------\nPonyfind Telemetry Report\n-------------------------\n\nReport Type:\n System Crash Report\n\n-------------------------\n\nReporter:\n " + interaction.user.tag + " (" + interaction.user.id + ")\n\nServer:\n " + interaction.guild.name + " (" + interaction.guild.id + ")\n\nChannel:\n " + interaction.channel.name + " (" + interaction.channel.id + ")\n\nItem:\n -\n\nReport Type:\n Automated Error Report\n\n-------------------------\n\n" + e.stack)
try {
await interaction.reply({
- ephemeral: false,
+ ephemeral: true,
embeds: [
new MessageEmbed()
.setColor('#dc2828')
.setTitle(l("An internal exception occurred", "Une erreur interne s'est produite", interaction.user.id, interaction.guild.id))
- .setDescription(l("That's not your fault! The developers have already been informed about the issue and will resolve it as soon as possible.", "Ce n'est pas votre faute ! Les développeurs ont déjà été informés du problème et il sera corrigé aussi vite que possible.", interaction.user.id, interaction.guild.id) + "\n\n```\n" + e.stack + "\n```")
- ],
- components: [
- new MessageActionRow()
- .addComponents(
- new MessageButton()
- .setCustomId("error.report")
- .setLabel(l("Send bug report", "Envoyer un rapport de bug", interaction.user.id, interaction.guild.id))
- .setStyle("DANGER")
- )
- ]
- });
- } catch (e) {
- await interaction.reply({
- ephemeral: false,
- embeds: [
- new MessageEmbed()
- .setColor('#dc2828')
- .setTitle("An internal exception occurred")
- .setDescription("That's not your fault! The developers have already been informed about the issue and will resolve it as soon as possible.\n\n```\n" + e.stack + "\n```")
- ],
- components: [
- new MessageActionRow()
- .addComponents(
- new MessageButton()
- .setCustomId("error.report")
- .setLabel("Send bug report")
- .setStyle("DANGER")
- )
+ .setDescription(l("That's not your fault! The developers have already been informed about the issue and will resolve it as soon as possible.", "Ce n'est pas votre faute ! Les développeurs ont déjà été informés du problème et il sera corrigé aussi vite que possible.", interaction.user.id, interaction.guild.id))
]
});
+ } catch (e2) {
+ fs.writeFileSync("./reports/Telemetry-Crash-" + (new Date().toISOString().replace(/[^a-zA-Z0-9]/gm, "-")) + ".txt", "-------------------------\nPonyfind Telemetry Report\n-------------------------\n\nReport Type:\n System Crash Report\n\n-------------------------\n\nReporter:\n " + interaction.user.tag + " (" + interaction.user.id + ")\n\nServer:\n " + interaction.guild.name + " (" + interaction.guild.id + ")\n\nChannel:\n " + interaction.channel.name + " (" + interaction.channel.id + ")\n\nItem:\n -\n\nReport Type:\n Automated Error Report (chained with " + e.message + ")\n\n-------------------------\n\n" + e2.stack)
+ try {
+ await interaction.reply({
+ ephemeral: true,
+ embeds: [
+ new MessageEmbed()
+ .setColor('#dc2828')
+ .setTitle("2 internal exceptions occurred")
+ .setDescription("That's not your fault! The developers have already been informed about the issue and will resolve it as soon as possible. We additionally weren't able to deliver you a localized error message.")
+ ]
+ });
+ } catch (e3) {
+ fs.writeFileSync("./reports/Telemetry-Crash-" + (new Date().toISOString().replace(/[^a-zA-Z0-9]/gm, "-")) + ".txt", "-------------------------\nPonyfind Telemetry Report\n-------------------------\n\nReport Type:\n System Crash Report\n\n-------------------------\n\nReporter:\n " + interaction.user.tag + " (" + interaction.user.id + ")\n\nServer:\n " + interaction.guild.name + " (" + interaction.guild.id + ")\n\nChannel:\n " + interaction.channel.name + " (" + interaction.channel.id + ")\n\nItem:\n -\n\nReport Type:\n Automated Error Report (chained with " + e.message + " and " + e2.message + ")\n\n-------------------------\n\n" + e3.stack)
+ try {
+ interaction.channel.send({embeds: [new MessageEmbed()
+ .setColor('#dc2828')
+ .setTitle("3 internal exceptions occurred")
+ .setDescription("That's not your fault! The developers have already been informed about the issue and will resolve it as soon as possible. We additionally weren't able to deliver you a localized error message and/or through a reply to your command.")]
+ }).catch((e4) => {
+ fs.writeFileSync("./reports/Telemetry-Crash-" + (new Date().toISOString().replace(/[^a-zA-Z0-9]/gm, "-")) + ".txt", "-------------------------\nPonyfind Telemetry Report\n-------------------------\n\nReport Type:\n System Crash Report\n\n-------------------------\n\nReporter:\n " + interaction.user.tag + " (" + interaction.user.id + ")\n\nServer:\n " + interaction.guild.name + " (" + interaction.guild.id + ")\n\nChannel:\n " + interaction.channel.name + " (" + interaction.channel.id + ")\n\nItem:\n -\n\nReport Type:\n Automated Error Report (chained with " + e.message + ", " + e2.message + " and " + e3.message + ")\n\n-------------------------\n\n" + e4.stack)
+ interaction.user.send({
+ embeds: [new MessageEmbed()
+ .setColor('#dc2828')
+ .setTitle("4 internal exceptions occurred")
+ .setDescription("That's not your fault! The developers have already been informed about the issue and will resolve it as soon as possible. We additionally weren't able to deliver you a localized error message, through a reply to your command and/or through the channel you initially executed the command.")]
+ })
+ })
+ } catch (e) {}
+ }
}
}
\ No newline at end of file |