mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
fixed
This commit is contained in:
1 parent
0d58b5441c
commit
a124236f9d
1 file changed
+49
@@ -1378,8 +1378,57 @@ export class GatewayHandler {
|
||||
* and rejoins 24/7 channels with staggered delays to avoid overwhelming
|
||||
* the LiveKit server.
|
||||
*/
|
||||
/**
|
||||
* Paginate /users/@me/guilds via REST and add any guilds that Fluxer
|
||||
* didn't cache (because their GUILD_CREATE was never received) as
|
||||
* lightweight stubs into client.guilds. This ensures guild count and
|
||||
* any guild-map lookups reflect the real server count.
|
||||
*
|
||||
* Stubs only carry { id, name } — enough for counting and ID lookups.
|
||||
* They are skipped if a full guild object is already in the cache.
|
||||
*/
|
||||
async seedGuildsFromRest() {
|
||||
const { remix } = this;
|
||||
const client = remix.client;
|
||||
|
||||
try {
|
||||
let after = null;
|
||||
let added = 0;
|
||||
|
||||
while (true) {
|
||||
const url = "/users/@me/guilds?limit=200" + (after ? "&after=" + after : "");
|
||||
const chunk = await client.rest.get(url);
|
||||
|
||||
if (!Array.isArray(chunk) || chunk.length === 0) break;
|
||||
|
||||
for (const g of chunk) {
|
||||
const id = g?.id;
|
||||
if (!id) continue;
|
||||
// Only add if not already cached by Fluxer
|
||||
if (!client.guilds.has(id)) {
|
||||
// Insert a minimal stub so .size and .get(id) work correctly
|
||||
client.guilds.set(id, { id, name: g.name ?? "unknown", _stub: true });
|
||||
added++;
|
||||
}
|
||||
}
|
||||
|
||||
if (chunk.length < 200) break;
|
||||
after = chunk[chunk.length - 1].id;
|
||||
}
|
||||
|
||||
if (added > 0) {
|
||||
logger.guild(`[GuildSeed] Added ${added} missing guild stub(s) from REST. Total: ${client.guilds.size}`);
|
||||
} else {
|
||||
logger.guild(`[GuildSeed] All guilds already cached. Total: ${client.guilds.size}`);
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn("[GuildSeed] REST guild seeding failed:", err?.message ?? err);
|
||||
}
|
||||
}
|
||||
|
||||
onReady() {
|
||||
this.seedVoiceStatesFromGuilds();
|
||||
this.seedGuildsFromRest(); // fill in guilds Fluxer didn't cache via GUILD_CREATE
|
||||
this.attachRawListener();
|
||||
|
||||
this.setupPresenceRotation();
|
||||
|
||||
Reference in new issue
Block a user