Skip to content

yuyo.chunk_tracker#

Utility class for tracking request guild member responses.

ChunkRequestFinishedEvent #

Bases: ShardEvent

Event that's dispatched when a specific chunk request has finished.

This will be fired for every chunk request which has a nonce.

chunk_count property #

chunk_count: int

The amount of chunk events which should've been received for this request.

first_received_at property #

first_received_at: datetime.datetime

When the first response was received.

guild_id property #

guild_id: hikari.Snowflake

Id of the guild this chunk request was for.

last_received_at property #

last_received_at: datetime.datetime

When the last response was received.

missed_chunks property #

missed_chunks: collections.Collection[int]

Collection of the chunk responses which were missed (if any).

not_found_ids property #

not_found_ids: collections.Collection[hikari.Snowflake]

Collection of the User IDs which weren't found.

This is only relevant when users was specified while requesting the members.

__init__ #

__init__(app, shard, data)

Initialise a chunk request finished event.

This should never be initialised directly.

ChunkTracker #

Chunk payload event tracker.

This will dispatch ShardFinishedChunkingEvent, FinishedChunkingEvent and ChunkRequestFinishedEvent events.

To configure this to automatically request member chunks to fill a member and/or presence cache on startup and guild join see ChunkTracker.set_auto_chunk_members.

Note

ChunkTracker.request_guild_members ensures a request will be tracked as this only tracks chunk requests with a set nonce.

__init__ #

__init__(event_manager, rest, shards, /, *, timeout=datetime.timedelta(seconds=5))

Initialise a chunk tracker.

For a shorthand for initialising this from a hikari.GatewayBotAware see ChunkTracker.from_gateway_bot.

Parameters:

  • event_manager (EventManager) –

    The event manager this chunk tracker should dispatch events over.

  • rest (RESTAware) –

    The REST aware object this should use.

  • shards (ShardAware) –

    The shard aware object this should use.

  • timeout (typing.Union[int, float, timedelta], default: datetime.timedelta(seconds=5) ) –

    How long this should wait between chunks until deciding the request has finished early/incomplete.

from_gateway_bot classmethod #

from_gateway_bot(bot, /, *, timeout=datetime.timedelta(seconds=5))

Initialise a chunk tracker from a gateway bot.

Parameters:

request_guild_members async #

request_guild_members(guild, /, *, include_presences=hikari.UNDEFINED, query='', limit=0, users=hikari.UNDEFINED)

Request guild members.

Note

To request the full list of members, leave query as "" (empty string) and limit as 0.

Parameters:

  • guild (hikari.SnowflakeishOr[hikari.PartialGuild]) –

    The guild to request chunk for.

  • include_presences (hikari.UndefinedOr[bool], default: UNDEFINED ) –

    If provided, whether to request presences.

  • query (str, default: '' ) –

    If not "", request the members who's usernames starts with the string.

  • limit (int, default: 0 ) –

    Maximum number of members to send matching the query.

  • users (hikari.UndefinedOr[hikari.SnowflakeishSequence[hikari.User]], default: UNDEFINED ) –

    If provided, the users to request for.

Raises:

  • ValueError

    When trying to specify users with query/limit, if limit is not between 0 and 100, both inclusive or if users length is over 100.

  • MissingIntentError

    When trying to request presences without the GUILD_MEMBERS or when trying to request the full list of members without GUILD_PRESENCES.

set_auto_chunk_members #

set_auto_chunk_members(state, /, *, chunk_presences=True)

Configure whether this should request member chunks in response to GUILD_CREATE.

This may be useful for filling 3rd party caches but may conflict with the auto_chunk_members config of hikari.impl.GatewayBot if it's enabled.

Warning

This will be ignored if Intents.GUILD_MEMBERS hasn't been declared.

Parameters:

  • state (bool) –

    Whether this should request member chunks when GUILD_CREATE events are received.

  • chunk_presences (bool, default: True ) –

    Whether this should also request member presences on these member chunks.

    This will be ignored if Intents.GUILD_PRESENCES hasn't been declared.

Returns:

  • Self

    The chunk tracker object to enable call chaining.

FinishedChunkingEvent #

Bases: Event

Event that's dispatched when the startup chunking has finished for the bot.

This indicates that the member and presence caches should be complete globally.

This will only be fired once after bot startups.

__init__ #

__init__(app)

Initialise a chunking finished event.

This should never be initialised directly.

ShardFinishedChunkingEvent #

Bases: ShardEvent

Event that's dispatched when the startup chunking has finished for a shard.

This indicates that the member and presence caches should be complete for guilds covered by this shard.

This will be fired after every shard identify which triggers chunking (including re-identifies).

incomplete_guild_ids property #

incomplete_guild_ids: collections.Sequence[hikari.Snowflake]

Sequence of the IDs of guilds some chunk responses were missed for.

missed_guild_ids property #

missed_guild_ids: collections.Sequence[hikari.Snowflake]

Sequence of the IDs of guilds no chunk responses were received for.

__init__ #

__init__(app, shard, /, *, incomplete_guild_ids=(), missed_guild_ids=())

Initialise a shard chunking finished event.

This should never be initialised directly.