Skip to content

hikari.impl.cache#

Basic implementation of a cache for general bots and gateway apps.

CacheImpl #

CacheImpl(app: RESTAware, settings: CacheSettings)

Bases: MutableCache

In-memory cache implementation.

PARAMETER DESCRIPTION
app

The object of the REST aware app this is bound to.

TYPE: RESTAware

settings

The cache settings to use.

TYPE: CacheSettings

settings property #

settings: CacheSettings

Get the configured settings for this cache.

clear #

clear() -> None

Clear the full cache.

clear_dm_channel_ids #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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.

get_available_guild #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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.

set_dm_channel_id #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

set_thread(thread: 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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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 #

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).