From 6392328c599469f75c47e2dffab46b4214bf87aa Mon Sep 17 00:00:00 2001 From: Alan Leal Date: Tue, 26 Mar 2024 21:44:44 -0300 Subject: [PATCH] Revert "v4.12.4 - Bug fix no event de erro duplicado" --- package.json | 2 +- src/client.js | 15 ++++++++++----- src/events/discord/interactionCreate.js | 23 +++-------------------- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 1520de9..bbd43e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kami", - "version": "4.12.4", + "version": "4.12.3", "description": "Um BOT para Discord com foco em ajudar em mesas de RPG online, tendo suas principais funções criar fichas e rolar dados.", "main": "index.js", "scripts": { diff --git a/src/client.js b/src/client.js index 9927513..699eb88 100644 --- a/src/client.js +++ b/src/client.js @@ -121,7 +121,7 @@ module.exports = class MenuClient extends Discord.Client { logging: false, dialect: "postgres", } - + if (process.env.NODE_ENV == "production") { conStr["dialectOptions"] = { ssl: { @@ -130,7 +130,7 @@ module.exports = class MenuClient extends Discord.Client { } } } - + return conStr } @@ -162,7 +162,9 @@ module.exports = class MenuClient extends Discord.Client { if (err == "TypeError: Cannot read property 'send' of null") { process.exit(1) } - + else if (err != "DiscordAPIError: Unknown interaction") { + this.emit("err", err, true) + } logs.log.error(err, true) errorStack++ @@ -177,7 +179,9 @@ module.exports = class MenuClient extends Discord.Client { if (err == "TypeError: Cannot read property 'send' of null") { process.exit(1) } - + else if (err != "DiscordAPIError: Unknown interaction") { + this.emit("err", err, true) + } logs.log.error(err, true) errorStack++ @@ -197,6 +201,7 @@ module.exports = class MenuClient extends Discord.Client { }) }) + } setCache() { @@ -259,7 +264,7 @@ module.exports = class MenuClient extends Discord.Client { } } - setWebSocket() { + setWebSocket(){ const ws = require("./modules/websocket/server") new ws(this) } diff --git a/src/events/discord/interactionCreate.js b/src/events/discord/interactionCreate.js index 7061c1e..bab0edc 100644 --- a/src/events/discord/interactionCreate.js +++ b/src/events/discord/interactionCreate.js @@ -36,25 +36,7 @@ module.exports = { return int.reply({ embeds: [disableEmbed], ephemeral: true }) } else { - try { - cmd.run(client, int) - .catch(err => { - client.log.error(err, true) - if (int.deferred) { - if (int.replied) { - return - } - else { - return int.editReply({ content: client.tl({ local: int.lang + "intCreate-onErr" }), ephemeral: true }) - } - } - else { - return int.reply({ content: client.tl({ local: int.lang + "intCreate-onErr" }), ephemeral: true }) - } - }) - } - catch (err) { - client.log.error(err, true) + client.on("err", (err, logged) => { if (int.deferred) { if (int.replied) { return @@ -66,8 +48,9 @@ module.exports = { else { return int.reply({ content: client.tl({ local: int.lang + "intCreate-onErr" }), ephemeral: true }) } - } + }) + cmd.run(client, int) client.emit("cmd", int, cmd.name) const args = client.utils.argsString(int) client.log.info(`Comando: ${cmd.name} executado por ${int.user.tag}(${int.user.id}) ${args ? `- Args: ${args}` : ``}`)