bug fixes

This commit is contained in:
2025-10-10 18:51:23 -04:00
parent 8236c1e0e7
commit 61ab1e1d9e
15 changed files with 4463 additions and 7 deletions

View File

@@ -42,6 +42,72 @@ module.exports = {
console.log('✅ Invite reconciliation complete: no stale invites found');
}
// Reconcile reaction roles: ensure stored message IDs still exist, remove stale configs
console.log('🔄 Reconciling reaction roles (initial check)...');
try {
for (const guildId of guildIds) {
try {
const rrList = await api.listReactionRoles(guildId) || [];
for (const rr of rrList) {
if (!rr.message_id) continue; // not posted yet
try {
const guild = client.guilds.cache.get(guildId);
if (!guild) continue;
const channel = await guild.channels.fetch(rr.channel_id || rr.channelId).catch(() => null);
if (!channel) {
// channel missing -> delete RR
await api.deleteReactionRole(guildId, rr.id);
continue;
}
const msg = await channel.messages.fetch(rr.message_id).catch(() => null);
if (!msg) {
// message missing -> delete RR
await api.deleteReactionRole(guildId, rr.id);
continue;
}
} catch (inner) {
// ignore per-item errors
}
}
} catch (e) {
// ignore guild-level errors
}
}
console.log('✅ Reaction role initial reconciliation complete');
} catch (e) {
console.error('Failed reaction role reconciliation:', e && e.message ? e.message : e);
}
// Periodic reconciliation every 10 minutes
setInterval(async () => {
try {
for (const guildId of client.guilds.cache.map(g => g.id)) {
const rrList = await api.listReactionRoles(guildId) || [];
for (const rr of rrList) {
if (!rr.message_id) continue;
try {
const guild = client.guilds.cache.get(guildId);
if (!guild) continue;
const channel = await guild.channels.fetch(rr.channel_id || rr.channelId).catch(() => null);
if (!channel) {
await api.deleteReactionRole(guildId, rr.id);
continue;
}
const msg = await channel.messages.fetch(rr.message_id).catch(() => null);
if (!msg) {
await api.deleteReactionRole(guildId, rr.id);
continue;
}
} catch (e) {
// ignore
}
}
}
} catch (e) {
// ignore
}
}, 10 * 60 * 1000);
const activities = [
{ name: 'Watch EhChad Live!', type: ActivityType.Streaming, url: 'https://twitch.tv/ehchad' },
{ name: 'Follow EhChad!', type: ActivityType.Streaming, url: 'https://twitch.tv/ehchad' },