pub trait Cache: Backend {
Show 28 methods fn current_user<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<CurrentUser, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn channel<'life0, 'async_trait>(
        &'life0 self,
        channel_id: Id<ChannelMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Option<CachedChannel>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn permission_overwrites<'life0, 'async_trait>(
        &'life0 self,
        channel_id: Id<ChannelMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CachedPermissionOverwrite>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn guild_channels<'life0, 'async_trait>(
        &'life0 self,
        guild_id: Id<GuildMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CachedChannel>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn message<'life0, 'async_trait>(
        &'life0 self,
        message_id: Id<MessageMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Option<CachedMessage>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn attachments<'life0, 'async_trait>(
        &'life0 self,
        message_id: Id<MessageMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CachedAttachment>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn reactions<'life0, 'async_trait>(
        &'life0 self,
        message_id: Id<MessageMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CachedReaction>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn stickers<'life0, 'async_trait>(
        &'life0 self,
        message_id: Id<MessageMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CachedSticker>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn channel_messages<'life0, 'async_trait>(
        &'life0 self,
        channel_id: Id<ChannelMarker>,
        limit: u16
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CachedMessage>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn member<'life0, 'async_trait>(
        &'life0 self,
        user_id: Id<UserMarker>,
        guild_id: Id<GuildMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Option<CachedMember>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn member_roles<'life0, 'async_trait>(
        &'life0 self,
        user_id: Id<UserMarker>,
        guild_id: Id<GuildMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CachedRole>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn presence<'life0, 'async_trait>(
        &'life0 self,
        user_id: Id<UserMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Option<CachedPresence>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn member_activities<'life0, 'async_trait>(
        &'life0 self,
        user_id: Id<UserMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CachedActivity>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn guild_members<'life0, 'async_trait>(
        &'life0 self,
        guild_id: Id<GuildMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CachedMember>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn guild<'life0, 'async_trait>(
        &'life0 self,
        guild_id: Id<GuildMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Option<CachedGuild>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn role<'life0, 'async_trait>(
        &'life0 self,
        role_id: Id<RoleMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Option<CachedRole>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn guild_roles<'life0, 'async_trait>(
        &'life0 self,
        guild_id: Id<GuildMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CachedRole>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn emoji<'life0, 'async_trait>(
        &'life0 self,
        emoji_id: Id<EmojiMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Option<CachedEmoji>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn guild_emojis<'life0, 'async_trait>(
        &'life0 self,
        guild_id: Id<GuildMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CachedEmoji>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn sticker<'life0, 'async_trait>(
        &'life0 self,
        sticker_id: Id<StickerMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Option<CachedSticker>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn guild_stickers<'life0, 'async_trait>(
        &'life0 self,
        guild_id: Id<GuildMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CachedSticker>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn stage_instance<'life0, 'async_trait>(
        &'life0 self,
        stage_id: Id<StageMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Option<StageInstance>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn update<'life0, 'life1, 'async_trait>(
        &'life0 self,
        event: &'life1 Event
    ) -> Pin<Box<dyn Future<Output = Result<(), Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: Sync + 'async_trait
, { ... } fn self_channel_permissions<'life0, 'async_trait>(
        &'life0 self,
        channel_id: Id<ChannelMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... } fn self_guild_permissions<'life0, 'async_trait>(
        &'life0 self,
        guild_id: Id<GuildMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... } fn channel_permissions<'life0, 'async_trait>(
        &'life0 self,
        user_id: Id<UserMarker>,
        channel_id: Id<ChannelMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... } fn guild_permissions<'life0, 'async_trait>(
        &'life0 self,
        user_id: Id<UserMarker>,
        guild_id: Id<GuildMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Permissions, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... } fn embeds<'life0, 'async_trait>(
        &'life0 self,
        message_id: Id<MessageMarker>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<(CachedEmbed, Vec<CachedEmbedField>)>, Error<Self::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... }
}
Expand description

Provides methods to update the cache and get data from it

This is for the users of the cache

Example

use twilight_model::id::Id;
cache.update(&event);
let channel = cache.channel(Id::new(123)).await?.unwrap();

Required Methods

Get the current user information of the bot

Errors

Returns Error::CurrentUserMissing when called before the ready event is received

Get a cached channel or thread by its ID

The users that are joined in a thread aren’t cached, as caching them is likely unnecessary, if you need them, please create an issue

Get a cached permission overwrites of a channel by its ID

Get a guild’s channels and threads by its ID

Get a cached message by its ID

The returned message doesn’t contain embeds, attachments, reactions or stickers, since they’re cached separately and the method doesn’t query them for you to reduce overhead in case you don’t need them

Get cached attachments of a message by its ID

Get cached reactions of a message by its ID

Get cached stickers of a message by its ID

Get a channel’s most recent limit messages by its ID

A limit of 0 means to return all messages

The messages are ordered from most recent to least recent

Get a cached member by its guild ID and user ID

Get cached roles of a member by their ID

Get cached presence of a member by their ID

Get cached activities of a member by their ID

Get a guild’s members by its ID

Get a cached guild by its ID

Get a cached role by its ID

Get a guild’s roles by its ID

Get a cached emoji by its ID

Get a guild’s emojis by its ID

Get a cached sticker by its ID

Get a guild’s stickers by its ID

Get a cached stage instance by its ID

Provided Methods

Update the cache with the given event, should be called for every event to keep the cache valid

Clones

Many events don’t require the event to be cloned, so the event parameter is taken by a reference, if an event does require a clone (usually add and update events), it will clone the required fields

Errors

Returns the error the backend might return

Get permissions of the current user in the given channel

This is a convenience method for Self::channel_permissions with the current user’s ID

Errors

Returns the error the backend might return

Returns Error::PermissionsChannelMissing, Error::PermissionsChannelNotInGuild, Error::PermissionsGuildMissing or Error::PermissionsGuildEveryoneRoleMissing

Get permissions of the current user in the given guild

This is a convenience method for Self::guild_permissions with the current user’s ID

Errors

Returns the error the backend might return

Returns Error::PermissionsGuildMissing or Error::PermissionsGuildEveryoneRoleMissing

Get the permissions of the given user and guild

Errors

Returns the error the backend might return

Returns Error::PermissionsGuildMissing, Error::PermissionsGuildEveryoneRoleMissing, Error::PermissionsMemberMissing or Error::MemberBadTimeoutTimestamp

Get cached embeds of a message by its ID

Implementors