pub struct CacheArgs {
pub guild_id: Id<GuildMarker>,
pub channel_id: Id<ChannelMarker>,
}Expand description
Arguments for cache operations.
Fields§
§guild_id: Id<GuildMarker>The ID of the guild.
channel_id: Id<ChannelMarker>The ID of the channel.
Implementations§
Source§impl CacheArgs
impl CacheArgs
Sourcepub async fn get(&self, http: &Client) -> Result<Channel>
pub async fn get(&self, http: &Client) -> Result<Channel>
Retrieves a guild channel from cache or fetches it from the API.
The returned channel is always in Self::guild_id. GUILD_CHANNEL_CACHE
is keyed by channel id alone, so a hit is verified against the requested
guild before it is returned; the remaining steps are already scoped to the
guild.
The result is only as fresh as the cache. invalidate_channel drops
entries when Discord reports a change and nothing survives the hour
regardless, but permission overwrites read from here can still lag a change
whose event never reached the bot.
The lookup order is:
- Individual channel cache
- Guild channel list cache
- Discord API (with cache update)
Sourceasync fn cached(&self) -> Result<Option<Channel>>
async fn cached(&self) -> Result<Option<Channel>>
Returns the cached channel, or None when nothing is cached for it or
what is cached was read before the latest channel change in the guild.
Sourceasync fn channel_list(
&self,
http: &Client,
) -> Result<Stamped<HashMap<Id<ChannelMarker>, Channel>>>
async fn channel_list( &self, http: &Client, ) -> Result<Stamped<HashMap<Id<ChannelMarker>, Channel>>>
Returns the guild’s channel list from cache, or from the Discord API when none is cached or the cached one predates a reported channel change.
Sourceasync fn get_channel_list_from_api(
&self,
http: &Client,
) -> Result<HashMap<Id<ChannelMarker>, Channel>>
async fn get_channel_list_from_api( &self, http: &Client, ) -> Result<HashMap<Id<ChannelMarker>, Channel>>
Fetches the channel list from the Discord API.
Self::channel_list stamps the result and inserts it into
GUILD_CHANNEL_LIST_CACHE, so this does not touch the cache itself.