Fixed Invite Accordion
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const { ActivityType } = require('discord.js');
|
||||
const deployCommands = require('../deploy-commands');
|
||||
const api = require('../api');
|
||||
|
||||
module.exports = {
|
||||
name: 'clientReady',
|
||||
@@ -16,6 +17,31 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
// Reconcile invites for all guilds to detect invites deleted while bot was offline
|
||||
console.log('🔄 Reconciling invites for offline changes...');
|
||||
let totalReconciled = 0;
|
||||
for (const guildId of guildIds) {
|
||||
try {
|
||||
const guild = client.guilds.cache.get(guildId);
|
||||
if (!guild) continue;
|
||||
|
||||
// Fetch current invites from Discord
|
||||
const discordInvites = await guild.invites.fetch();
|
||||
const currentInvites = Array.from(discordInvites.values());
|
||||
|
||||
// Reconcile with database
|
||||
const reconciled = await api.reconcileInvites(guildId, currentInvites);
|
||||
totalReconciled += reconciled;
|
||||
} catch (e) {
|
||||
console.error(`Failed to reconcile invites for guild ${guildId}:`, e && e.message ? e.message : e);
|
||||
}
|
||||
}
|
||||
if (totalReconciled > 0) {
|
||||
console.log(`✅ Invite reconciliation complete: removed ${totalReconciled} stale invites`);
|
||||
} else {
|
||||
console.log('✅ Invite reconciliation complete: no stale invites found');
|
||||
}
|
||||
|
||||
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' },
|
||||
|
||||
Reference in New Issue
Block a user