Files
SnazzahandTTtie 4110a7449b feat: allow channel/thread->guild and guild->shard maps to be disabled (#222)
This should allow for not using the `Client.channelGuildMap`,
`Client.threadGuildMap`, and `Client.guildShardMap` when
`caching.disableMaps` is on.

Some caveats:
- Obviously `getChannel` will do linear searching now, but this can be
skipped with guild hinting. `getChannel` now has a `guildIDHint`
parameter for getting that specific guild rather than searching all of
them. Which has some caveats:
- `editChannelPosition`'s option param has `guildIDHint`, it's channel's
corresponding function will use it.
- Same for `joinVoiceChannel` and `leaveVoiceChannel`, but
`leaveVoiceChannel` has it's hinting in a new parameter.
- `ThreadMember`'s construction to find the guild *will* do linear
searching, sad.
- Many of the shard events that use `getChannel` either now hint at the
guild or just gets the guild directly.

---------

Co-authored-by: TTtie <me@tttie.cz>
2026-05-11 01:04:11 +02:00

37 lines
796 B
JavaScript

"use strict";
const Base = require("./Base");
/**
* Represents a guild
* @extends Base
*/
class UnavailableGuild extends Base {
/**
* The ID of the guild
* @member {String} UnavailableGuild#id
*/
constructor(data, client) {
super(data.id);
/**
* The shard that owns this guild
* @type {Shard}
*/
this.shard = client.shards.get(client.guildShardMap[this.id] ?? client.shards.resolveFromGuild(this.id));
/**
* Whether the guild is unavailable or not
* @type {Boolean}
*/
this.unavailable = !!data.unavailable;
}
toJSON(props = []) {
return super.toJSON([
"unavailable",
...props
]);
}
}
module.exports = UnavailableGuild;