pub struct CacheArgs {
pub guild_id: GuildId,
pub channel_id: ChannelId,
}Expand description
Arguments for cache operations.
Fields§
§guild_id: GuildIdThe ID of the guild.
channel_id: ChannelIdThe ID of the channel.
Implementations§
Source§impl CacheArgs
impl CacheArgs
Sourcepub async fn get(&self, ctx: &Context) -> Result<GuildChannel>
pub async fn get(&self, ctx: &Context) -> Result<GuildChannel>
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 get_channel_list_from_api(
&self,
ctx: &Context,
) -> Result<HashMap<ChannelId, GuildChannel>>
async fn get_channel_list_from_api( &self, ctx: &Context, ) -> Result<HashMap<ChannelId, GuildChannel>>
Fetches the channel list from the Discord API.
The caller inserts the result into GUILD_CHANNEL_LIST_CACHE via
try_get_with, so this does not touch the cache itself.