diff --git a/index.js b/index.js index 6a256c5..7acf665 100644 --- a/index.js +++ b/index.js @@ -576,7 +576,28 @@ xmpp.on("stanza", (stanza) => { thisMsg.content = row.custommessage || null; user.send(thisMsg).catch((err) => { console.error(err); - }); + }).catch((err) => { + console.log(`${colors.yellow("[WARN]")} Failed to send message to ${user.tag} (${user.id})`); + const logChannel = discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.logChannel); + logChannel.send({ + embeds: [ + { + title: "Failed to send DM", + description: `User may have DMs disabled, or bot doesnt' share a server anymore!. + User: ${user.tag} (${user.id}) + Sub Info: \`\`\`json\n${JSON.stringify(row)}\`\`\``, + color: 0xff0000 + } + ] + }).then(() => { + db.run(`DELETE FROM userAlerts WHERE userid = ? AND iemchannel = ?`, [user.id, fromChannel], (err) => { + if (err) { + console.error(err.message); + } + console.log(`${colors.cyan("[INFO]")} Deleted user ${user.id} from database`); + }); + }) + } }); }).catch((err) => { setTimeout(() => { @@ -1568,6 +1589,8 @@ discord.on("guildCreate", async (guild) => { ] } ] + }).catch((err) => { + console.log(`${colors.red("[ERROR]")} Failed to send message to user ${user.id}: ${err.message}`); }) channel.send({ embeds: [