Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.12.4 - Bug fix no event de erro duplicado #31

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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