게이트웨이와 캐시¶
bostie.gateway.GatewayClient
¶
GatewayClient(bridge: Bridge, token: str, *, intents: int, shard_count: int, shard_ids: Iterable[int], large_threshold: int = start, session_file: Path | None = None)
The bot's gateway shards: send commands, reconnect, and measure latency.
latency
property
¶
latency: float | None
Mean seconds from a heartbeat to its ACK over shards that measured one.
shard
¶
The shard with this id; ValueError when this process does not run it.
send
¶
Send a gateway command to the shards it belongs to.
Op 3 goes to every shard, a payload with a guild_id to that guild's shard, one with guild_ids to each of their shards with its share of the ids, and anything else to shard 0. Replies arrive only for event names someone listens to.
bostie.gateway.Shard
¶
Shard(bridge: Bridge, shard_id: int)
bostie.RequestedMembers
dataclass
¶
bostie.cache.Cache
¶
Cache(max_messages: int = 0, *, members: bool = False, presences: bool = False, max_dm_channels: int = 0)
Guilds, channels, active threads, voice states and the bot's member and user.
Scheduled events, stage instances and soundboard sounds are kept too.
Members, presences, the latest messages and DM channels are kept only when asked for. Channels are stored as received, obfuscated ones included, except the fields CHANNEL_UPDATE does not keep current (last_message_id, message_count, member_count, last_pin_timestamp), which are None.
guild_channels
¶
The guild's channels, active threads included.
voice_state
¶
voice_state(guild_id: int, user_id: int) -> VoiceState | None
The user's voice state, or None when they are in no voice channel.
guild_voice_states
¶
guild_voice_states(guild_id: int) -> list[VoiceState]
Everyone in a voice channel of the guild.
member
¶
A member; only the bot's own unless the cache keeps members.
presence
¶
A member's presence when the cache keeps presences; None when offline.
guild_presences
¶
The presences of the guild's members who are not offline.
dm_channel
¶
The bot's DM channel with a user, if it is one of the latest kept.
permissions
¶
permissions(channel_id: int, member: AnyMember | None = None) -> Permissions | None
A member's permissions in a channel, else the bot's; None if unknown.
guild_permissions
¶
guild_permissions(guild_id: int, member: AnyMember | None = None) -> Permissions | None
A member's guild-wide permissions, else the bot's; None if unknown.