hikari.api.cache#

Core interface for a cache implementation.

Module Contents#

class hikari.api.cache.Cache[source]#

Bases: abc.ABC

Interface describing the operations a cache component should provide.

This will be used by the gateway to cache specific types of objects that the application should attempt to remember for later, depending on how this is implemented. The requirement for this stems from the assumption by Discord that bot applications will maintain some form of “memory” of the events that occur.

The implementation may choose to use a simple in-memory collection of objects, or may decide to use a distributed system such as a Redis cache for cross-process bots.

abstract property settings: hikari.api.config.CacheSettings[source]#

Get the configured settings for this cache.

abstract get_available_guild(guild, /)[source]#

Get the object of an available guild from the cache.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get from the cache.

Returns:
typing.Optional[hikari.guilds.GatewayGuild]

The object of the guild if found, else None.

abstract get_available_guilds_view()[source]#

Get a view of the available guild objects in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.guilds.GatewayGuild]

A view of guild IDs to the guild objects found in the cache.

abstract get_dm_channel_id(user, /)[source]#

Get the DM channel ID for a user.

Parameters:
userhikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]

Object or ID of the user to get the DM channel ID for.

Returns:
typing.Optional[hikari.snowflakes.Snowflake]

ID of the DM channel which was found cached for the supplied user or None.

abstract get_dm_channel_ids_view()[source]#

Get a view of the cached DM channel IDs.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.snowflakes.Snowflake]

Cache view of user IDs to DM channel IDs.

abstract get_emoji(emoji, /)[source]#

Get a known custom emoji from the cache.

Parameters:
emojihikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji]

Object or ID of the emoji to get from the cache.

Returns:
typing.Optional[hikari.emojis.KnownCustomEmoji]

The object of the emoji that was found in the cache or None.

abstract get_emojis_view()[source]#

Get a view of the known custom emoji objects in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji]

A view of emoji IDs to objects of the known custom emojis found in the cache.

abstract get_emojis_view_for_guild(guild, /)[source]#

Get a view of the known custom emojis cached for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get the cached emoji objects for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji]

A view of emoji IDs to objects of emojis found in the cache for the specified guild.

abstract get_guild(guild, /)[source]#

Get a guild from the cache.

Warning

This will return a guild regardless of whether it is available or not. To only query available guilds, use get_available_guild instead. Likewise, to only query unavailable guilds, use get_unavailable_guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get from the cache.

Returns:
typing.Optional[hikari.guilds.GatewayGuild]

The object of the guild if found, else None.

abstract get_guild_channel(channel, /)[source]#

Get a guild channel from the cache.

Parameters:
channelhikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]

Object or ID of the guild channel to get from the cache.

Returns:
typing.Optional[hikari.channels.PermissibleGuildChannel]

The object of the guild channel that was found in the cache or None.

abstract get_guild_channels_view()[source]#

Get a view of the guild channels in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.channels.PermissibleGuildChannel]

A view of channel IDs to objects of the guild channels found in the cache.

abstract get_guild_channels_view_for_guild(guild, /)[source]#

Get a view of the guild channels in the cache for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get the cached channels for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.channels.PermissibleGuildChannel]

A view of channel IDs to objects of the guild channels found in the cache for the specified guild.

abstract get_guilds_view()[source]#

Get a view of all the guild objects in the cache regardless if availability.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.guilds.GatewayGuild]

A view of guild IDs to the guild objects found in the cache.

abstract get_invite(code, /)[source]#

Get an invite object from the cache.

Parameters:
codetyping.Union[hikari.invites.InviteCode, str]

The object or string code of the invite to get from the cache.

Returns:
typing.Optional[hikari.invites.InviteWithMetadata]

The object of the invite that was found in the cache or None.

abstract get_invites_view()[source]#

Get a view of the invite objects in the cache.

Returns:
CacheView[str, hikari.invites.InviteWithMetadata]

A view of string codes to objects of the invites that were found in the cache.

abstract get_invites_view_for_channel(guild, channel, /)[source]#

Get a view of the invite objects in the cache for a specified channel.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get invite objects for.

channelhikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]

Object or ID of the channel to get invite objects for.

Returns:
CacheView[str, invites.InviteWithMetadata]

A view of string codes to objects of the invites there were found in the cache for the specified channel.

abstract get_invites_view_for_guild(guild, /)[source]#

Get a view of the invite objects in the cache for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get invite objects for.

Returns:
CacheView[str, hikari.invites.InviteWithMetadata]

A view of string code to objects of the invites that were found in the cache for the specified guild.

abstract get_me()[source]#

Get the own user object from the cache.

Returns:
typing.Optional[hikari.users.OwnUser]

The own user object that was found in the cache, else None.

abstract get_member(guild, user, /)[source]#

Get a member object from the cache.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get a cached member for.

userhikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]

Object or ID of the user to get a cached member for.

Returns:
typing.Optional[hikari.guilds.Member]

The object of the member found in the cache, else None.

abstract get_members_view()[source]#

Get a view of all the members objects in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, CacheView[hikari.snowflakes.Snowflake, hikari.guilds.Member]]

A view of guild IDs to views of user IDs to objects of the members that were found from the cache.

abstract get_members_view_for_guild(guild_id, /)[source]#

Get a view of the members cached for a specific guild.

Parameters:
guild_idhikari.snowflakes.Snowflakeish

The ID of the guild to get the cached member view for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.guilds.Member]

The view of user IDs to the members cached for the specified guild.

abstract get_message(message, /)[source]#

Get a message object from the cache.

Parameters:
messagehikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage]

Object or ID of the message to get from the cache.

Returns:
typing.Optional[hikari.messages.Message]

The object of the message found in the cache or None.

abstract get_messages_view()[source]#

Get a view of all the message objects in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.messages.Message]

A view of message objects found in the cache.

abstract get_presence(guild, user, /)[source]#

Get a presence object from the cache.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get a presence for.

userhikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]

Object or ID of the user to get a presence for.

Returns:
typing.Optional[hikari.presences.MemberPresence]

The object of the presence that was found in the cache or None.

abstract get_presences_view()[source]#

Get a view of all the presence objects in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, CacheView[hikari.snowflakes.Snowflake]]

A view of guild IDs to views of user IDs to objects of the presences found in the cache.

abstract get_presences_view_for_guild(guild, /)[source]#

Get a view of the presence objects in the cache for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get the cached presence objects for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence]

A view of user IDs to objects of the presence found in the cache for the specified guild.

abstract get_role(role, /)[source]#

Get a role object from the cache.

Parameters:
rolehikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole]

Object or ID of the role to get from the cache.

Returns:
typing.Optional[hikari.guilds.Role]

The object of the role found in the cache or None.

abstract get_roles_view()[source]#

Get a view of all the role objects in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.guilds.Role]

A view of role IDs to objects of the roles found in the cache.

abstract get_roles_view_for_guild(guild, /)[source]#

Get a view of the roles in the cache for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get the cached roles for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.guilds.Role]

A view of role IDs to objects of the roles that were found in the cache for the specified guild.

abstract get_sticker(sticker, /)[source]#

Get a sticker from the cache.

Parameters:
stickerhikari.snowflakes.SnowflakeishOr[hikari.stickers.GuildSticker]

Object or ID of the sticker to get from the cache.

Returns:
typing.Optional[hikari.stickers.GuildSticker]

The object of the sticker that was found in the cache or None.

abstract get_stickers_view()[source]#

Get a view of the sticker objects in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.stickers.GuildSticker]

A view of sticker IDs to objects of the stickers found in the cache.

abstract get_stickers_view_for_guild(guild, /)[source]#

Get a view of the known custom emojis cached for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get the cached sticker objects for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.stickers.GuildSticker]

A view of sticker IDs to objects of stickers found in the cache for the specified guild.

abstract get_thread(thread, /)[source]#

Get a thread channel from the cache.

Parameters:
threadhikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]

Object or ID of the thread to get from the cache.

Returns:
typing.Optional[hikari.channels.GuildThreadChannel]

The object of the thread that was found in the cache or None.

abstract get_threads_view()[source]#

Get a view of the thread channels in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.channels.GuildThreadChannel]

A view of channel IDs to objects of the thread channels found in the cache.

abstract get_threads_view_for_channel(guild, channel, /)[source]#

Get a view of the thread channels in the cache for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get the cached thread channels for.

channelhikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]

Object or ID of the channel to get the cached thread channels for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.channels.GuildThreadChannel]

A view of channel IDs to objects of the thread channels found in the cache for the specified channel.

abstract get_threads_view_for_guild(guild, /)[source]#

Get a view of the thread channels in the cache for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get the cached thread channels for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.channels.GuildThreadChannel]

A view of channel IDs to objects of the thread channels found in the cache for the specified guild.

abstract get_unavailable_guild(guild, /)[source]#

Get the object of a unavailable guild from the cache.

Note

Unlike Cache.get_available_guild, the objects returned by this method will likely be out of date and inaccurate as they are considered unavailable, meaning that we are not receiving gateway events for this guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get from the cache.

Returns:
typing.Optional[hikari.guilds.GatewayGuild]

The object of the guild if found, else None.

abstract get_unavailable_guilds_view()[source]#

Get a view of the unavailable guild objects in the cache.

Note

Unlike Cache.get_available_guilds_view, the objects returned by this method will likely be out of date and inaccurate as they are considered unavailable, meaning that we are not receiving gateway events for this guild.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.guilds.GatewayGuild]

A view of guild IDs to the guild objects found in the cache.

abstract get_user(user, /)[source]#

Get a user object from the cache.

Parameters:
userhikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]

Object or ID of the user to get from the cache.

Returns:
typing.Optional[hikari.users.User]

The object of the user that was found in the cache, else None.

abstract get_users_view()[source]#

Get a view of the user objects in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.users.User]

The view of user IDs to the users found in the cache.

abstract get_voice_state(guild, user, /)[source]#

Get a voice state object from the cache.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get a voice state for.

userhikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]

Object or ID of the user to get a voice state for.

Returns:
typing.Optional[hikari.voices.VoiceState]

The object of the voice state that was found in the cache, or None.

abstract get_voice_states_view()[source]#

Get a view of all the voice state objects in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, CacheView[hikari.snowflakes.Snowflake, hikari.voices.VoiceState]]

A view of guild IDs to views of user IDs to objects of the voice states that were found in the cache.

abstract get_voice_states_view_for_channel(guild, channel, /)[source]#

Get a view of the voice states cached for a specific channel.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get the cached voice states for.

channelhikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]

Object or ID of the channel to get the cached voice states for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.voices.VoiceState]

A view of user IDs to objects of the voice states found cached for the specified channel.

abstract get_voice_states_view_for_guild(guild, /)[source]#

Get a view of the voice states cached for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to get the cached voice states for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.voices.VoiceState]

A view of user IDs to objects of the voice states found cached for the specified guild.

class hikari.api.cache.CacheView[source]#

Bases: Mapping[_KeyT, _ValueT], abc.ABC

Interface describing an immutable snapshot view of part of a cache.

This can be treated as a normal typing.Mapping but with some special methods.

abstract get_item_at(index, /)[source]#
abstract get_item_at(index: slice, /) Sequence[_ValueT]

Get an item at a specific position or slice.

class hikari.api.cache.MutableCache[source]#

Bases: Cache, abc.ABC

Cache that exposes read-only operations as well as mutation operations.

This is only exposed to internal components. There is no guarantee the user-facing cache will provide these methods or not.

abstract clear()[source]#

Clear the full cache.

abstract clear_dm_channel_ids()[source]#

Remove all the cached DM channel IDs.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.snowflakes.Snowflake]

Cache view of user IDs to DM channel IDs which were cleared from the cache.

abstract clear_emojis()[source]#

Remove all the known custom emoji objects from the cache.

Note

This will skip emojis that are being kept alive by a reference on a presence entry.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji]

A cache view of emoji IDs to objects of the emojis that were removed from the cache.

abstract clear_emojis_for_guild(guild, /)[source]#

Remove the known custom emoji objects cached for a specific guild.

Note

This will skip emojis that are being kept alive by a reference on a presence entry.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove the cached emoji objects for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.emojis.KnownCustomEmoji]

A view of emoji IDs to objects of the emojis that were removed from the cache.

abstract clear_guild_channels()[source]#

Remove all guild channels from the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.channels.PermissibleGuildChannel]

A view of channel IDs to objects of the guild channels that were removed from the cache.

abstract clear_guild_channels_for_guild(guild, /)[source]#

Remove guild channels from the cache for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove cached channels for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.channels.PermissibleGuildChannel]

A view of channel IDs to objects of the guild channels that were removed from the cache.

abstract clear_guilds()[source]#

Remove all the guild objects from the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.guilds.GatewayGuild]

The cache view of guild IDs to guild objects that were removed from the cache.

abstract clear_invites()[source]#

Remove all the invite objects from the cache.

Returns:
CacheView[str, hikari.invites.InviteWithMetadata]

A view of invite code strings to objects of the invites that were removed from the cache.

abstract clear_invites_for_channel(guild, channel, /)[source]#

Remove the invite objects in the cache for a specific channel.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove invite objects for.

channelhikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]

Object or ID of the channel to remove invite objects for.

Returns:
CacheView[str, hikari.invites.InviteWithMetadata]

A view of invite code strings to objects of the invites that were removed from the cache for the specified channel.

abstract clear_invites_for_guild(guild, /)[source]#

Remove the invite objects in the cache for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove invite objects for.

Returns:
CacheView[str, hikari.invites.InviteWithMetadata]

A view of invite code strings to objects of the invites that were removed from the cache for the specified guild.

abstract clear_members()[source]#

Remove all the guild members in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, CacheView[hikari.snowflakes.Snowflake, hikari.guilds.Member]]

A view of guild IDs to views of user IDs to objects of the members that were removed from the cache.

abstract clear_members_for_guild(guild, /)[source]#

Remove the members for a specific guild from the cache.

Note

This will skip members that are being referenced by other entries in the cache; a matching voice state will keep a member entry alive.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove cached members for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.guilds.Member]

The view of user IDs to the member objects that were removed from the cache.

abstract clear_messages()[source]#

Remove all message objects from the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.messages.Message]

A view of message objects that were removed from the cache.

abstract clear_presences()[source]#

Remove all the presences in the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, CacheView[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence]]

A view of guild IDs to views of user IDs to objects of the presences that were removed from the cache.

abstract clear_presences_for_guild(guild, /)[source]#

Remove the presences in the cache for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove presences for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.presences.MemberPresence]

A view of user IDs to objects of the presences that were removed from the cache for the specified guild.

abstract clear_roles()[source]#

Remove all role objects from the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.guilds.Role]

A view of role IDs to objects of the roles that were removed from the cache.

abstract clear_roles_for_guild(guild, /)[source]#

Remove role objects from the cache for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove roles for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.guilds.Role]

A view of role IDs to objects of the roles that were removed from the cache for the specific guild.

abstract clear_stickers()[source]#

Remove all the sticker objects from the cache.

Note

This will skip stickers that are being kept alive by a reference.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.stickers.GuildSticker]

A cache view of sticker IDs to objects of the stickers that were removed from the cache.

abstract clear_stickers_for_guild(guild, /)[source]#

Remove the known custom emoji objects cached for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove the cached sticker objects for.

.. note::

This will skip stickers that are being kept alive by a reference.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.stickers.GuildSticker]

A view of sticker IDs to objects of the stickers that were removed from the cache.

abstract clear_threads()[source]#

Remove all thread channels from the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.channels.GuildThreadChannel]

A view of channel IDs to objects of the thread channels that were removed from the cache.

abstract clear_threads_for_channel(guild, channel, /)[source]#

Remove thread channels from the cache for a specific channel.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove cached threads for.

channelhikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]

Object or ID of the channel to remove cached threads for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.channels.GuildThreadChannel]

A view of channel IDs to objects of the thread channels that were removed from the cache.

abstract clear_threads_for_guild(guild, /)[source]#

Remove thread channels from the cache for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove cached threads for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.channels.GuildThreadChannel]

A view of channel IDs to objects of the thread channels that were removed from the cache.

abstract clear_voice_states()[source]#

Remove all voice state objects from the cache.

Returns:
CacheView[hikari.snowflakes.Snowflake, CacheView[hikari.snowflakes.Snowflake, hikari.voices.VoiceState]]

A view of guild IDs to views of user IDs to objects of the voice states that were removed from the states.

abstract clear_voice_states_for_channel(guild, channel, /)[source]#

Remove the voice state objects cached for a specific channel.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove voice states for.

channelhikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]

Object or ID of the channel to remove voice states for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.voices.VoiceState]

A view of user IDs to objects of the voice state that were removed from the cache for the specified channel.

abstract clear_voice_states_for_guild(guild, /)[source]#

Clear the voice state objects cached for a specific guild.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove cached voice states for.

Returns:
CacheView[hikari.snowflakes.Snowflake, hikari.voices.VoiceState]

A view of user IDs to the voice state objects that were removed from the cache.

abstract delete_dm_channel_id(user, /)[source]#

Remove a DM channel ID from the cache.

Parameters:
userhikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]

Object or ID of the user to remove the cached DM channel ID for.

Returns:
typing.Optional[hikari.snowflakes.Snowflake]

The DM channel ID which was removed from the cache if found, else None.

abstract delete_emoji(emoji, /)[source]#

Remove a known custom emoji from the cache.

Note

This will not delete emojis that are being kept alive by a reference on a presence entry.

Parameters:
emojihikari.snowflakes.SnowflakeishOr[hikari.emojis.CustomEmoji]

Object or ID of the emoji to remove from the cache.

Returns:
typing.Optional[hikari.emojis.KnownCustomEmoji]

The object of the emoji that was removed from the cache or None.

abstract delete_guild(guild, /)[source]#

Remove a guild object from the cache.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove from the cache.

Returns:
typing.Optional[hikari.guilds.GatewayGuild]

The object of the guild that was removed from the cache, will be None if not found.

abstract delete_guild_channel(channel, /)[source]#

Remove a guild channel from the cache.

Parameters:
channelhikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]

Object or ID of the guild channel to remove from the cache.

Returns:
typing.Optional[hikari.channels.PermissibleGuildChannel]

The object of the guild channel that was removed from the cache if found, else None.

abstract delete_invite(code, /)[source]#

Remove an invite object from the cache.

Parameters:
codetyping.Union[hikari.invites.InviteCode, str]

Object or string code of the invite to remove from the cache.

Returns:
typing.Optional[hikari.invites.InviteWithMetadata]

The object of the invite that was removed from the cache if found, else None.

abstract delete_me()[source]#

Remove the own user object from the cache.

Returns:
typing.Optional[hikari.users.OwnUser]

The own user object that was removed from the cache if found, else None.

abstract delete_member(guild, user, /)[source]#

Remove a member object from the cache.

Note

You cannot delete a member entry that’s being referenced by other entries in the cache; a matching voice state will keep a member entry alive.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove a member from the cache for.

userhikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]

Object or ID of the user to remove a member from the cache for.

Returns:
typing.Optional[hikari.guilds.Member]

The object of the member that was removed from the cache if found, else None.

abstract delete_message(message, /)[source]#

Remove a message object from the cache.

Parameters:
messagehikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage]

Object or ID of the messages to remove the cache.

Returns:
typing.Optional[hikari.messages.Message]

The object of the message that was removed from the cache if found, else None.

abstract delete_presence(guild, user, /)[source]#

Remove a presence from the cache.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to remove a presence for.

userhikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]

Object or ID of the user to remove a presence for.

Returns:
typing.Optional[hikari.presences.MemberPresence]

The object of the presence that was removed from the cache if found, else None.

abstract delete_role(role, /)[source]#

Remove a role object form the cache.

Parameters:
rolehikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialRole]

Object or ID of the role to remove from the cache.

Returns:
typing.Optional[hikari.guilds.Role]

The object of the role that was removed from the cache if found, else None.

abstract delete_sticker(sticker, /)[source]#

Remove a sticker from the cache.

Note

This will not delete stickers that are being kept alive by a reference.

Parameters:
stickerhikari.snowflakes.SnowflakeishOr[hikari.stickers.GuildSticker]

Object or ID of the sticker to remove from the cache.

Returns:
typing.Optional[hikari.stickers.GuildSticker]

The object of the sticker that was removed from the cache or None.

abstract delete_thread(thread, /)[source]#

Remove a thread channel from the cache.

Parameters:
threadhikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]

Object or ID of the thread to remove from the cache.

Returns:
typing.Optional[hikari.channels.GuildThreadChannel]

The object of the thread that was removed from the cache if found, else None.

abstract delete_voice_state(guild, user, /)[source]#

Remove a voice state object from the cache.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild the voice state to remove is related to.

userhikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]

Object or ID of the user who the voice state to remove belongs to.

Returns:
typing.Optional[hikari.voices.VoiceState]

The object of the voice state that was removed from the cache if found, else None.

abstract set_dm_channel_id(user, channel, /)[source]#

Add a DM channel ID to the cache.

Parameters:
userhikari.snowflakes.SnowflakeishOr[hikari.users.PartialUser]

Object or ID of the user to add a DM channel ID to the cache for.

channelhikari.snowflakes.SnowflakeishOr[hikari.channels.PartialChannel]

Object or ID of the DM channel to add to the cache.

abstract set_emoji(emoji, /)[source]#

Add a known custom emoji to the cache.

Parameters:
emojihikari.emojis.KnownCustomEmoji

The object of the known custom emoji to add to the cache.

abstract set_guild(guild, /)[source]#

Add a guild object to the cache.

Parameters:
guildhikari.guilds.GatewayGuild

The object of the guild to add to the cache.

abstract set_guild_availability(guild, is_available, /)[source]#

Set whether a cached guild is available or not.

Parameters:
guildhikari.snowflakes.SnowflakeishOr[hikari.guilds.PartialGuild]

Object or ID of the guild to set the availability for.

is_availablebool

The availability to set for the guild.

abstract set_guild_channel(channel, /)[source]#

Add a guild channel to the cache.

Parameters:
channelhikari.channels.PermissibleGuildChannel

The guild channel based object to add to the cache.

abstract set_invite(invite, /)[source]#

Add an invite object to the cache.

Parameters:
invitehikari.invites.InviteWithMetadata

The object of the invite to add to the cache.

abstract set_me(user, /)[source]#

Set the own user object in the cache.

Parameters:
userhikari.users.OwnUser

The own user object to set in the cache.

abstract set_member(member, /)[source]#

Add a member object to the cache.

Parameters:
memberhikari.guilds.Member

The object of the member to add to the cache.

abstract set_message(message, /)[source]#

Add a message object to the cache.

Parameters:
messagehikari.messages.Message

The object of the message to add to the cache.

abstract set_presence(presence, /)[source]#

Add a presence object to the cache.

Parameters:
presencehikari.presences.MemberPresence

The object of the presence to add to the cache.

abstract set_role(role, /)[source]#

Add a role object to the cache.

Parameters:
rolehikari.guilds.Role

The object of the role to add to the cache.

abstract set_sticker(sticker, /)[source]#

Add a sticker to the cache.

Parameters:
stickerhikari.stickers.GuildSticker

The object of the sticker to add to the cache.

abstract set_thread(channel, /)[source]#

Add a thread channel to the cache.

Parameters:
channelhikari.channels.GuildThreadChannel

The thread channel based object to add to the cache.

abstract set_voice_state(voice_state, /)[source]#

Add a voice state object to the cache.

Parameters:
voice_statehikari.voices.VoiceState

The object of the voice state to add to the cache.

abstract update_emoji(emoji, /)[source]#

Update an emoji object in the cache.

Parameters:
emojihikari.emojis.KnownCustomEmoji

The object of the emoji to update in the cache.

Returns:
typing.Tuple[typing.Optional[hikari.emojis.KnownCustomEmoji], typing.Optional[hikari.emojis.KnownCustomEmoji]]

A tuple of the old cached emoji object if found (else None) and the new cached emoji object if it could be cached (else None).

abstract update_guild(guild, /)[source]#

Update a guild in the cache.

Parameters:
guildhikari.guilds.GatewayGuild

The object of the guild to update in the cache.

Returns:
typing.Tuple[typing.Optional[hikari.guilds.GatewayGuild], typing.Optional[hikari.guilds.GatewayGuild]]

A tuple of the old cached guild object if found (else None) and the object of the guild that was added to the cache if it could be added (else None).

abstract update_guild_channel(channel, /)[source]#

Update a guild channel in the cache.

Parameters:
channelhikari.channels.PermissibleGuildChannel

The object of the channel to update in the cache.

Returns:
typing.Tuple[typing.Optional[hikari.channels.PermissibleGuildChannel], typing.Optional[hikari.channels.PermissibleGuildChannel]]

A tuple of the old cached guild channel if found (else None) and the new cached guild channel if it could be cached (else None).

abstract update_invite(invite, /)[source]#

Update an invite in the cache.

Parameters:
invitehikari.invites.InviteWithMetadata

The object of the invite to update in the cache.

Returns:
typing.Tuple[typing.Optional[hikari.invites.InviteWithMetadata], typing.Optional[hikari.invites.InviteWithMetadata]]

A tuple of the old cached invite object if found (else None) and the new cached invite object if it could be cached (else None).

abstract update_me(user, /)[source]#

Update the own user entry in the cache.

Parameters:
userhikari.users.OwnUser

The own user object to update in the cache.

Returns:
typing.Tuple[typing.Optional[hikari.users.OwnUser], typing.Optional[hikari.users.OwnUser]]

A tuple of the old cached own user object if found (else None) and the new cached own user object if it could be cached, else None.

abstract update_member(member, /)[source]#

Update a member in the cache.

Parameters:
memberhikari.guilds.Member

The object of the member to update in the cache.

Returns:
typing.Tuple[typing.Optional[hikari.guilds.Member], typing.Optional[hikari.guilds.Member]]

A tuple of the old cached member object if found (else None) and the new cached member object if it could be cached (else None).

abstract update_message(message, /)[source]#

Update a message in the cache.

Parameters:
messagetyping.Union[hikari.messages.PartialMessage, hikari.messages.Message]

The object of the message to update in the cache.

Returns:
typing.Tuple[typing.Optional[hikari.messages.Message], typing.Optional[hikari.messages.Message]]

A tuple of the old cached message object if found (else None) and the new cached message object if it could be cached (else None).

abstract update_presence(presence, /)[source]#

Update a presence object in the cache.

Parameters:
presencehikari.presences.MemberPresence

The object of the presence to update in the cache.

Returns:
typing.Tuple[typing.Optional[hikari.presences.MemberPresence], typing.Optional[hikari.presences.MemberPresence]]

A tuple of the old cached invite object if found (else None and the new cached invite object if it could be cached ( else None).

abstract update_role(role, /)[source]#

Update a role in the cache.

Parameters:
rolehikari.guilds.Role

The object of the role to update in the cache.

Returns:
typing.Tuple[typing.Optional[hikari.guilds.Role], typing.Optional[hikari.guilds.Role]]

A tuple of the old cached role object if found (else None and the new cached role object if it could be cached (else None).

abstract update_thread(thread, /)[source]#

Update a thread channel in the cache.

Parameters:
threadhikari.channels.GuildThreadChannel

The object of the thread channel to update in the cache.

Returns:
typing.Tuple[typing.Optional[hikari.channels.GuildThreadChannel], typing.Optional[hikari.channels.GuildThreadChannel]]

A tuple of the old cached thread channel if found (else None) and the new cached thread channel if it could be cached (else None).

abstract update_voice_state(voice_state, /)[source]#

Update a voice state object in the cache.

Parameters:
voice_statehikari.voices.VoiceState

The object of the voice state to update in the cache.

Returns:
typing.Tuple[typing.Optional[hikari.voices.VoiceState], typing.Optional[hikari.voices.VoiceState]]

A tuple of the old cached voice state if found (else None) and the new cached voice state object if it could be cached (else None).