Fetch all alert users at startup

This commit is contained in:
Christopher Cookman 2024-05-22 12:51:49 -06:00
parent 54eb401093
commit 9393bf8f94
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -456,7 +456,6 @@ xmpp.on("stanza", (stanza) => {
// If the event type is not in th filter, ignore it. Make sure filterEvt isnt null // If the event type is not in th filter, ignore it. Make sure filterEvt isnt null
if (!filterEvt[0]) filterEvt = []; if (!filterEvt[0]) filterEvt = [];
if (!filterEvt.includes(evt.code.toLowerCase()) && !filterEvt.length == 0) return; if (!filterEvt.includes(evt.code.toLowerCase()) && !filterEvt.length == 0) return;
let user = discord.users.cache.get(row.userid); let user = discord.users.cache.get(row.userid);
if (!user) return console.log(`${colors.red("[ERROR]")} User ${row.userid} not found`); if (!user) return console.log(`${colors.red("[ERROR]")} User ${row.userid} not found`);
@ -678,6 +677,16 @@ discord.on('ready', async () => {
}; };
}); });
}); });
// Get all users in userAlerts and fetch them
db.all(`SELECT userid FROM userAlerts`, (err, rows) => {
if (err) {
console.error(err.message);
}
rows.forEach((row) => {
discord.users.fetch(row.userid);
});
});
}); });
discord.on("interactionCreate", async (interaction) => { discord.on("interactionCreate", async (interaction) => {