Skip to content

hikari.api.cache#

Core interface for a cache implementation.

Cache #

Bases: 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.

settings abstractmethod property #

settings: CacheSettings

Get the configured settings for this cache.

get_available_guild abstractmethod #

get_available_guild(guild: SnowflakeishOr[PartialGuild]) -> Optional[GatewayGuild]

Get the object of an available guild from the cache.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
Optional[GatewayGuild]

The object of the guild if found, else None.

get_available_guilds_view abstractmethod #

get_available_guilds_view() -> CacheView[Snowflake, GatewayGuild]

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

RETURNS DESCRIPTION
CacheView[Snowflake, GatewayGuild]

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

get_dm_channel_id abstractmethod #

get_dm_channel_id(user: SnowflakeishOr[PartialUser]) -> Optional[Snowflake]

Get the DM channel ID for a user.

PARAMETER DESCRIPTION
user

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

TYPE: SnowflakeishOr[PartialUser]

RETURNS DESCRIPTION
Optional[Snowflake]

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

get_dm_channel_ids_view abstractmethod #

get_dm_channel_ids_view() -> CacheView[Snowflake, Snowflake]

Get a view of the cached DM channel IDs.

RETURNS DESCRIPTION
CacheView[Snowflake, Snowflake]

Cache view of user IDs to DM channel IDs.

get_emoji abstractmethod #

Get a known custom emoji from the cache.

PARAMETER DESCRIPTION
emoji

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

TYPE: SnowflakeishOr[CustomEmoji]

RETURNS DESCRIPTION
Optional[KnownCustomEmoji]

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

get_emojis_view abstractmethod #

get_emojis_view() -> CacheView[Snowflake, KnownCustomEmoji]

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

RETURNS DESCRIPTION
CacheView[Snowflake, KnownCustomEmoji]

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

get_emojis_view_for_guild abstractmethod #

get_emojis_view_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, KnownCustomEmoji]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, KnownCustomEmoji]

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

get_guild abstractmethod #

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 hikari.api.cache.Cache.get_available_guild instead. Likewise, to only query unavailable guilds, use hikari.api.cache.Cache.get_unavailable_guild.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
Optional[GatewayGuild]

The object of the guild if found, else None.

get_guild_channel abstractmethod #

Get a guild channel from the cache.

PARAMETER DESCRIPTION
channel

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

TYPE: SnowflakeishOr[PartialChannel]

RETURNS DESCRIPTION
Optional[PermissibleGuildChannel]

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

get_guild_channels_view abstractmethod #

get_guild_channels_view() -> CacheView[Snowflake, PermissibleGuildChannel]

Get a view of the guild channels in the cache.

RETURNS DESCRIPTION
CacheView[Snowflake, PermissibleGuildChannel]

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

get_guild_channels_view_for_guild abstractmethod #

get_guild_channels_view_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, PermissibleGuildChannel]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, PermissibleGuildChannel]

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

get_guilds_view abstractmethod #

get_guilds_view() -> CacheView[Snowflake, GatewayGuild]

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

RETURNS DESCRIPTION
CacheView[Snowflake, GatewayGuild]

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

get_invite abstractmethod #

Get an invite object from the cache.

PARAMETER DESCRIPTION
code

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

TYPE: Union[InviteCode, str]

RETURNS DESCRIPTION
Optional[InviteWithMetadata]

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

get_invites_view abstractmethod #

get_invites_view() -> CacheView[str, InviteWithMetadata]

Get a view of the invite objects in the cache.

RETURNS DESCRIPTION
CacheView[str, InviteWithMetadata]

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

get_invites_view_for_channel abstractmethod #

get_invites_view_for_channel(guild: SnowflakeishOr[PartialGuild], channel: SnowflakeishOr[PartialChannel]) -> CacheView[str, InviteWithMetadata]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

channel

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

TYPE: SnowflakeishOr[PartialChannel]

RETURNS DESCRIPTION
CacheView[str, InviteWithMetadata]

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

get_invites_view_for_guild abstractmethod #

get_invites_view_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[str, InviteWithMetadata]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[str, InviteWithMetadata]

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

get_me abstractmethod #

get_me() -> Optional[OwnUser]

Get the own user object from the cache.

RETURNS DESCRIPTION
Optional[OwnUser]

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

get_member abstractmethod #

Get a member object from the cache.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

user

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

TYPE: SnowflakeishOr[PartialUser]

RETURNS DESCRIPTION
Optional[Member]

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

get_members_view abstractmethod #

get_members_view() -> CacheView[Snowflake, CacheView[Snowflake, Member]]

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

RETURNS DESCRIPTION
CacheView[Snowflake, CacheView[Snowflake, Member]]

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

get_members_view_for_guild abstractmethod #

get_members_view_for_guild(guild_id: Snowflakeish) -> CacheView[Snowflake, Member]

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

PARAMETER DESCRIPTION
guild_id

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

TYPE: Snowflakeish

RETURNS DESCRIPTION
CacheView[Snowflake, Member]

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

get_message abstractmethod #

get_message(message: SnowflakeishOr[PartialMessage]) -> Optional[Message]

Get a message object from the cache.

PARAMETER DESCRIPTION
message

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

TYPE: SnowflakeishOr[PartialMessage]

RETURNS DESCRIPTION
Optional[Message]

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

get_messages_view abstractmethod #

get_messages_view() -> CacheView[Snowflake, Message]

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

RETURNS DESCRIPTION
CacheView[Snowflake, Message]

A view of message objects found in the cache.

get_presence abstractmethod #

Get a presence object from the cache.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

user

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

TYPE: SnowflakeishOr[PartialUser]

RETURNS DESCRIPTION
Optional[MemberPresence]

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

get_presences_view abstractmethod #

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

RETURNS DESCRIPTION
CacheView[Snowflake, CacheView[Snowflake]]

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

get_presences_view_for_guild abstractmethod #

get_presences_view_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, MemberPresence]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, MemberPresence]

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

get_role abstractmethod #

get_role(role: SnowflakeishOr[PartialRole]) -> Optional[Role]

Get a role object from the cache.

PARAMETER DESCRIPTION
role

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

TYPE: SnowflakeishOr[PartialRole]

RETURNS DESCRIPTION
Optional[Role]

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

get_roles_view abstractmethod #

get_roles_view() -> CacheView[Snowflake, Role]

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

RETURNS DESCRIPTION
CacheView[Snowflake, Role]

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

get_roles_view_for_guild abstractmethod #

get_roles_view_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, Role]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, Role]

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

get_sticker abstractmethod #

get_sticker(sticker: SnowflakeishOr[GuildSticker]) -> Optional[GuildSticker]

Get a sticker from the cache.

PARAMETER DESCRIPTION
sticker

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

TYPE: SnowflakeishOr[GuildSticker]

RETURNS DESCRIPTION
Optional[GuildSticker]

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

get_stickers_view abstractmethod #

get_stickers_view() -> CacheView[Snowflake, GuildSticker]

Get a view of the sticker objects in the cache.

RETURNS DESCRIPTION
CacheView[Snowflake, GuildSticker]

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

get_stickers_view_for_guild abstractmethod #

get_stickers_view_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, GuildSticker]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, GuildSticker]

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

get_thread abstractmethod #

Get a thread channel from the cache.

PARAMETER DESCRIPTION
thread

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

TYPE: SnowflakeishOr[PartialChannel]

RETURNS DESCRIPTION
Optional[GuildThreadChannel]

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

get_threads_view abstractmethod #

get_threads_view() -> CacheView[Snowflake, GuildThreadChannel]

Get a view of the thread channels in the cache.

RETURNS DESCRIPTION
CacheView[Snowflake, GuildThreadChannel]

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

get_threads_view_for_channel abstractmethod #

get_threads_view_for_channel(guild: SnowflakeishOr[PartialGuild], channel: SnowflakeishOr[PartialChannel]) -> CacheView[Snowflake, GuildThreadChannel]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

channel

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

TYPE: SnowflakeishOr[PartialChannel]

RETURNS DESCRIPTION
CacheView[Snowflake, GuildThreadChannel]

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

get_threads_view_for_guild abstractmethod #

get_threads_view_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, GuildThreadChannel]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, GuildThreadChannel]

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

get_unavailable_guild abstractmethod #

get_unavailable_guild(guild: SnowflakeishOr[PartialGuild]) -> Optional[GatewayGuild]

Get the object of an unavailable guild from the cache.

Note

Unlike hikari.api.cache.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.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
Optional[GatewayGuild]

The object of the guild if found, else None.

get_unavailable_guilds_view abstractmethod #

get_unavailable_guilds_view() -> CacheView[Snowflake, GatewayGuild]

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

Note

Unlike hikari.api.cache.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 DESCRIPTION
CacheView[Snowflake, GatewayGuild]

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

get_user abstractmethod #

get_user(user: SnowflakeishOr[PartialUser]) -> Optional[User]

Get a user object from the cache.

PARAMETER DESCRIPTION
user

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

TYPE: SnowflakeishOr[PartialUser]

RETURNS DESCRIPTION
Optional[User]

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

get_users_view abstractmethod #

get_users_view() -> CacheView[Snowflake, User]

Get a view of the user objects in the cache.

RETURNS DESCRIPTION
CacheView[Snowflake, User]

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

get_voice_state abstractmethod #

Get a voice state object from the cache.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

user

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

TYPE: SnowflakeishOr[PartialUser]

RETURNS DESCRIPTION
Optional[VoiceState]

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

get_voice_states_view abstractmethod #

get_voice_states_view() -> CacheView[Snowflake, CacheView[Snowflake, VoiceState]]

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

RETURNS DESCRIPTION
CacheView[Snowflake, CacheView[Snowflake, VoiceState]]

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

get_voice_states_view_for_channel abstractmethod #

get_voice_states_view_for_channel(guild: SnowflakeishOr[PartialGuild], channel: SnowflakeishOr[PartialChannel]) -> CacheView[Snowflake, VoiceState]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

channel

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

TYPE: SnowflakeishOr[PartialChannel]

RETURNS DESCRIPTION
CacheView[Snowflake, VoiceState]

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

get_voice_states_view_for_guild abstractmethod #

get_voice_states_view_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, VoiceState]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, VoiceState]

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

CacheView #

Bases: Mapping[_KeyT, _ValueT], 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.

get_item_at abstractmethod #

get_item_at(index: Union[slice, int]) -> Union[_ValueT, Sequence[_ValueT]]

Get an item at a specific position or slice.

MutableCache #

Bases: Cache, 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.

clear abstractmethod #

clear() -> None

Clear the full cache.

clear_dm_channel_ids abstractmethod #

clear_dm_channel_ids() -> CacheView[Snowflake, Snowflake]

Remove all the cached DM channel IDs.

RETURNS DESCRIPTION
CacheView[Snowflake, Snowflake]

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

clear_emojis abstractmethod #

clear_emojis() -> CacheView[Snowflake, KnownCustomEmoji]

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 DESCRIPTION
CacheView[Snowflake, KnownCustomEmoji]

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

clear_emojis_for_guild abstractmethod #

clear_emojis_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, KnownCustomEmoji]

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.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, KnownCustomEmoji]

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

clear_guild_channels abstractmethod #

clear_guild_channels() -> CacheView[Snowflake, PermissibleGuildChannel]

Remove all guild channels from the cache.

RETURNS DESCRIPTION
CacheView[Snowflake, PermissibleGuildChannel]

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

clear_guild_channels_for_guild abstractmethod #

clear_guild_channels_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, PermissibleGuildChannel]

Remove guild channels from the cache for a specific guild.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, PermissibleGuildChannel]

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

clear_guilds abstractmethod #

clear_guilds() -> CacheView[Snowflake, GatewayGuild]

Remove all the guild objects from the cache.

RETURNS DESCRIPTION
CacheView[Snowflake, GatewayGuild]

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

clear_invites abstractmethod #

clear_invites() -> CacheView[str, InviteWithMetadata]

Remove all the invite objects from the cache.

RETURNS DESCRIPTION
CacheView[str, InviteWithMetadata]

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

clear_invites_for_channel abstractmethod #

clear_invites_for_channel(guild: SnowflakeishOr[PartialGuild], channel: SnowflakeishOr[PartialChannel]) -> CacheView[str, InviteWithMetadata]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

channel

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

TYPE: SnowflakeishOr[PartialChannel]

RETURNS DESCRIPTION
CacheView[str, InviteWithMetadata]

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

clear_invites_for_guild abstractmethod #

clear_invites_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[str, InviteWithMetadata]

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[str, InviteWithMetadata]

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

clear_members abstractmethod #

clear_members() -> CacheView[Snowflake, CacheView[Snowflake, Member]]

Remove all the guild members in the cache.

RETURNS DESCRIPTION
CacheView[Snowflake, CacheView[Snowflake, Member]]

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

clear_members_for_guild abstractmethod #

clear_members_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, Member]

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.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, Member]

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

clear_messages abstractmethod #

clear_messages() -> CacheView[Snowflake, Message]

Remove all message objects from the cache.

RETURNS DESCRIPTION
CacheView[Snowflake, Message]

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

clear_presences abstractmethod #

Remove all the presences in the cache.

RETURNS DESCRIPTION
CacheView[Snowflake, CacheView[Snowflake, MemberPresence]]

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

clear_presences_for_guild abstractmethod #

clear_presences_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, MemberPresence]

Remove the presences in the cache for a specific guild.

PARAMETER DESCRIPTION
guild

Object or ID of the guild to remove presences for.

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, MemberPresence]

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

clear_roles abstractmethod #

clear_roles() -> CacheView[Snowflake, Role]

Remove all role objects from the cache.

RETURNS DESCRIPTION
CacheView[Snowflake, Role]

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

clear_roles_for_guild abstractmethod #

clear_roles_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, Role]

Remove role objects from the cache for a specific guild.

PARAMETER DESCRIPTION
guild

Object or ID of the guild to remove roles for.

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, Role]

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

clear_stickers abstractmethod #

clear_stickers() -> CacheView[Snowflake, GuildSticker]

Remove all the sticker objects from the cache.

Note

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

RETURNS DESCRIPTION
CacheView[Snowflake, GuildSticker]

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

clear_stickers_for_guild abstractmethod #

clear_stickers_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, GuildSticker]

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

Note

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

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, GuildSticker]

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

clear_threads abstractmethod #

clear_threads() -> CacheView[Snowflake, GuildThreadChannel]

Remove all thread channels from the cache.

RETURNS DESCRIPTION
CacheView[Snowflake, GuildThreadChannel]

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

clear_threads_for_channel abstractmethod #

Remove thread channels from the cache for a specific channel.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

channel

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

TYPE: SnowflakeishOr[PartialChannel]

RETURNS DESCRIPTION
CacheView[Snowflake, GuildThreadChannel]

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

clear_threads_for_guild abstractmethod #

clear_threads_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, GuildThreadChannel]

Remove thread channels from the cache for a specific guild.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, GuildThreadChannel]

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

clear_voice_states abstractmethod #

clear_voice_states() -> CacheView[Snowflake, CacheView[Snowflake, VoiceState]]

Remove all voice state objects from the cache.

RETURNS DESCRIPTION
CacheView[Snowflake, CacheView[Snowflake, VoiceState]]

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

clear_voice_states_for_channel abstractmethod #

clear_voice_states_for_channel(guild: SnowflakeishOr[PartialGuild], channel: SnowflakeishOr[PartialChannel]) -> CacheView[Snowflake, VoiceState]

Remove the voice state objects cached for a specific channel.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

channel

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

TYPE: SnowflakeishOr[PartialChannel]

RETURNS DESCRIPTION
CacheView[Snowflake, VoiceState]

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

clear_voice_states_for_guild abstractmethod #

clear_voice_states_for_guild(guild: SnowflakeishOr[PartialGuild]) -> CacheView[Snowflake, VoiceState]

Clear the voice state objects cached for a specific guild.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
CacheView[Snowflake, VoiceState]

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

delete_dm_channel_id abstractmethod #

delete_dm_channel_id(user: SnowflakeishOr[PartialUser]) -> Optional[Snowflake]

Remove a DM channel ID from the cache.

PARAMETER DESCRIPTION
user

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

TYPE: SnowflakeishOr[PartialUser]

RETURNS DESCRIPTION
Optional[Snowflake]

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

delete_emoji abstractmethod #

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.

PARAMETER DESCRIPTION
emoji

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

TYPE: SnowflakeishOr[CustomEmoji]

RETURNS DESCRIPTION
Optional[KnownCustomEmoji]

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

delete_guild abstractmethod #

Remove a guild object from the cache.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

RETURNS DESCRIPTION
Optional[GatewayGuild]

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

delete_guild_channel abstractmethod #

delete_guild_channel(channel: SnowflakeishOr[PartialChannel]) -> Optional[PermissibleGuildChannel]

Remove a guild channel from the cache.

PARAMETER DESCRIPTION
channel

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

TYPE: SnowflakeishOr[PartialChannel]

RETURNS DESCRIPTION
Optional[PermissibleGuildChannel]

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

delete_invite abstractmethod #

delete_invite(code: Union[InviteCode, str]) -> Optional[InviteWithMetadata]

Remove an invite object from the cache.

PARAMETER DESCRIPTION
code

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

TYPE: Union[InviteCode, str]

RETURNS DESCRIPTION
Optional[InviteWithMetadata]

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

delete_me abstractmethod #

delete_me() -> Optional[OwnUser]

Remove the own user object from the cache.

RETURNS DESCRIPTION
Optional[OwnUser]

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

delete_member abstractmethod #

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.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

user

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

TYPE: SnowflakeishOr[PartialUser]

RETURNS DESCRIPTION
Optional[Member]

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

delete_message abstractmethod #

delete_message(message: SnowflakeishOr[PartialMessage]) -> Optional[Message]

Remove a message object from the cache.

PARAMETER DESCRIPTION
message

Object or ID of the messages to remove the cache.

TYPE: SnowflakeishOr[PartialMessage]

RETURNS DESCRIPTION
Optional[Message]

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

delete_presence abstractmethod #

Remove a presence from the cache.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

user

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

TYPE: SnowflakeishOr[PartialUser]

RETURNS DESCRIPTION
Optional[MemberPresence]

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

delete_role abstractmethod #

delete_role(role: SnowflakeishOr[PartialRole]) -> Optional[Role]

Remove a role object form the cache.

PARAMETER DESCRIPTION
role

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

TYPE: SnowflakeishOr[PartialRole]

RETURNS DESCRIPTION
Optional[Role]

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

delete_sticker abstractmethod #

delete_sticker(sticker: SnowflakeishOr[GuildSticker]) -> Optional[GuildSticker]

Remove a sticker from the cache.

Note

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

PARAMETER DESCRIPTION
sticker

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

TYPE: SnowflakeishOr[GuildSticker]

RETURNS DESCRIPTION
Optional[GuildSticker]

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

delete_thread abstractmethod #

Remove a thread channel from the cache.

PARAMETER DESCRIPTION
thread

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

TYPE: SnowflakeishOr[PartialChannel]

RETURNS DESCRIPTION
Optional[GuildThreadChannel]

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

delete_voice_state abstractmethod #

delete_voice_state(guild: SnowflakeishOr[PartialGuild], user: SnowflakeishOr[PartialUser]) -> Optional[VoiceState]

Remove a voice state object from the cache.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

user

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

TYPE: SnowflakeishOr[PartialUser]

RETURNS DESCRIPTION
Optional[VoiceState]

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

set_dm_channel_id abstractmethod #

set_dm_channel_id(user: SnowflakeishOr[PartialUser], channel: SnowflakeishOr[PartialChannel]) -> None

Add a DM channel ID to the cache.

PARAMETER DESCRIPTION
user

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

TYPE: SnowflakeishOr[PartialUser]

channel

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

TYPE: SnowflakeishOr[PartialChannel]

set_emoji abstractmethod #

set_emoji(emoji: KnownCustomEmoji) -> None

Add a known custom emoji to the cache.

PARAMETER DESCRIPTION
emoji

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

TYPE: KnownCustomEmoji

set_guild abstractmethod #

set_guild(guild: GatewayGuild) -> None

Add a guild object to the cache.

PARAMETER DESCRIPTION
guild

The object of the guild to add to the cache.

TYPE: GatewayGuild

set_guild_availability abstractmethod #

set_guild_availability(guild: SnowflakeishOr[PartialGuild], is_available: bool) -> None

Set whether a cached guild is available or not.

PARAMETER DESCRIPTION
guild

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

TYPE: SnowflakeishOr[PartialGuild]

is_available

The availability to set for the guild.

TYPE: bool

set_guild_channel abstractmethod #

set_guild_channel(channel: PermissibleGuildChannel) -> None

Add a guild channel to the cache.

PARAMETER DESCRIPTION
channel

The guild channel based object to add to the cache.

TYPE: PermissibleGuildChannel

set_invite abstractmethod #

set_invite(invite: InviteWithMetadata) -> None

Add an invite object to the cache.

PARAMETER DESCRIPTION
invite

The object of the invite to add to the cache.

TYPE: InviteWithMetadata

set_me abstractmethod #

set_me(user: OwnUser) -> None

Set the own user object in the cache.

PARAMETER DESCRIPTION
user

The own user object to set in the cache.

TYPE: OwnUser

set_member abstractmethod #

set_member(member: Member) -> None

Add a member object to the cache.

PARAMETER DESCRIPTION
member

The object of the member to add to the cache.

TYPE: Member

set_message abstractmethod #

set_message(message: Message) -> None

Add a message object to the cache.

PARAMETER DESCRIPTION
message

The object of the message to add to the cache.

TYPE: Message

set_presence abstractmethod #

set_presence(presence: MemberPresence) -> None

Add a presence object to the cache.

PARAMETER DESCRIPTION
presence

The object of the presence to add to the cache.

TYPE: MemberPresence

set_role abstractmethod #

set_role(role: Role) -> None

Add a role object to the cache.

PARAMETER DESCRIPTION
role

The object of the role to add to the cache.

TYPE: Role

set_sticker abstractmethod #

set_sticker(sticker: GuildSticker) -> None

Add a sticker to the cache.

PARAMETER DESCRIPTION
sticker

The object of the sticker to add to the cache.

TYPE: GuildSticker

set_thread abstractmethod #

set_thread(channel: GuildThreadChannel) -> None

Add a thread channel to the cache.

PARAMETER DESCRIPTION
channel

The thread channel based object to add to the cache.

TYPE: GuildThreadChannel

set_voice_state abstractmethod #

set_voice_state(voice_state: VoiceState) -> None

Add a voice state object to the cache.

PARAMETER DESCRIPTION
voice_state

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

TYPE: VoiceState

update_emoji abstractmethod #

Update an emoji object in the cache.

PARAMETER DESCRIPTION
emoji

The object of the emoji to update in the cache.

TYPE: KnownCustomEmoji

RETURNS DESCRIPTION
Tuple[Optional[KnownCustomEmoji], Optional[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).

update_guild abstractmethod #

Update a guild in the cache.

PARAMETER DESCRIPTION
guild

The object of the guild to update in the cache.

TYPE: GatewayGuild

RETURNS DESCRIPTION
Tuple[Optional[GatewayGuild], Optional[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).

update_guild_channel abstractmethod #

Update a guild channel in the cache.

PARAMETER DESCRIPTION
channel

The object of the channel to update in the cache.

TYPE: PermissibleGuildChannel

RETURNS DESCRIPTION
Tuple[Optional[PermissibleGuildChannel], Optional[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).

update_invite abstractmethod #

Update an invite in the cache.

PARAMETER DESCRIPTION
invite

The object of the invite to update in the cache.

TYPE: InviteWithMetadata

RETURNS DESCRIPTION
Tuple[Optional[InviteWithMetadata], Optional[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).

update_me abstractmethod #

update_me(user: OwnUser) -> tuple[Optional[OwnUser], Optional[OwnUser]]

Update the own user entry in the cache.

PARAMETER DESCRIPTION
user

The own user object to update in the cache.

TYPE: OwnUser

RETURNS DESCRIPTION
Tuple[Optional[OwnUser], Optional[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.

update_member abstractmethod #

update_member(member: Member) -> tuple[Optional[Member], Optional[Member]]

Update a member in the cache.

PARAMETER DESCRIPTION
member

The object of the member to update in the cache.

TYPE: Member

RETURNS DESCRIPTION
Tuple[Optional[Member], Optional[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).

update_message abstractmethod #

update_message(message: Union[PartialMessage, Message]) -> tuple[Optional[Message], Optional[Message]]

Update a message in the cache.

PARAMETER DESCRIPTION
message

The object of the message to update in the cache.

TYPE: Union[PartialMessage, Message]

RETURNS DESCRIPTION
Tuple[Optional[Message], Optional[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).

update_presence abstractmethod #

Update a presence object in the cache.

PARAMETER DESCRIPTION
presence

The object of the presence to update in the cache.

TYPE: MemberPresence

RETURNS DESCRIPTION
Tuple[Optional[MemberPresence], Optional[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).

update_role abstractmethod #

update_role(role: Role) -> tuple[Optional[Role], Optional[Role]]

Update a role in the cache.

PARAMETER DESCRIPTION
role

The object of the role to update in the cache.

TYPE: Role

RETURNS DESCRIPTION
Tuple[Optional[Role], Optional[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).

update_thread abstractmethod #

Update a thread channel in the cache.

PARAMETER DESCRIPTION
thread

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

TYPE: GuildThreadChannel

RETURNS DESCRIPTION
Tuple[Optional[GuildThreadChannel], Optional[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).

update_voice_state abstractmethod #

update_voice_state(voice_state: VoiceState) -> tuple[Optional[VoiceState], Optional[VoiceState]]

Update a voice state object in the cache.

PARAMETER DESCRIPTION
voice_state

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

TYPE: VoiceState

RETURNS DESCRIPTION
Tuple[Optional[VoiceState], Optional[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).