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
The amount of chunk events which should've been received for this request.
missed_chunks property
#
missed_chunks
Collection of the chunk responses which were missed (if any).
not_found_ids property
#
not_found_ids
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
(Union[int, float, timedelta]
, default: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:
-
bot
(ShardAware & RESTAware & EventManagerAware
) –The gateway bot this chunk tracker should use.
-
timeout
(Union[int, float, timedelta]
, default:timedelta(seconds=5)
) –How long this should wait between chunks until deciding the request has finished early/incomplete.
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
(SnowflakeishOr[PartialGuild]
) –The guild to request chunk for.
-
include_presences
(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
(UndefinedOr[SnowflakeishSequence[User]]
, default:UNDEFINED
) –If provided, the users to request for.
Raises:
-
ValueError
–When trying to specify
users
withquery
/limit
, iflimit
is not between 0 and 100, both inclusive or ifusers
length is over 100. -
MissingIntentError
–When trying to request presences without the
GUILD_MEMBERS
or when trying to request the full list of members withoutGUILD_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
Sequence of the IDs of guilds some chunk responses were missed for.
missed_guild_ids property
#
missed_guild_ids
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.