Skip to content

Commit

Permalink
v4.12.4 - Bug fix no event de erro duplicado
Browse files Browse the repository at this point in the history
  • Loading branch information
alanfilho184 committed Mar 27, 2024
1 parent 018476e commit 8693ada
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kami",
"version": "4.12.3",
"version": "4.12.4",
"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": {
Expand Down
15 changes: 5 additions & 10 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ module.exports = class MenuClient extends Discord.Client {
logging: false,
dialect: "postgres",
}

if (process.env.NODE_ENV == "production") {
conStr["dialectOptions"] = {
ssl: {
Expand All @@ -130,7 +130,7 @@ module.exports = class MenuClient extends Discord.Client {
}
}
}

return conStr
}

Expand Down Expand Up @@ -162,9 +162,7 @@ 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++
Expand All @@ -179,9 +177,7 @@ 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++
Expand All @@ -201,7 +197,6 @@ module.exports = class MenuClient extends Discord.Client {
})

})

}

setCache() {
Expand Down Expand Up @@ -264,7 +259,7 @@ module.exports = class MenuClient extends Discord.Client {
}
}

setWebSocket(){
setWebSocket() {
const ws = require("./modules/websocket/server")
new ws(this)
}
Expand Down
23 changes: 20 additions & 3 deletions src/events/discord/interactionCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,25 @@ module.exports = {
return int.reply({ embeds: [disableEmbed], ephemeral: true })
}
else {
client.on("err", (err, logged) => {
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)
if (int.deferred) {
if (int.replied) {
return
Expand All @@ -48,9 +66,8 @@ 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}` : ``}`)
Expand Down

0 comments on commit 8693ada

Please sign in to comment.