Channels¶
channels
¶
GuildChannelCacheAddon
¶
Bases: Addon
flowchart TD
scurrypy.ext.cache.channels.GuildChannelCacheAddon[GuildChannelCacheAddon]
scurrypy.bases.addon.Addon[Addon]
scurrypy.bases.addon.Addon --> scurrypy.ext.cache.channels.GuildChannelCacheAddon
click scurrypy.ext.cache.channels.GuildChannelCacheAddon href "" "scurrypy.ext.cache.channels.GuildChannelCacheAddon"
click scurrypy.bases.addon.Addon href "" "scurrypy.bases.addon.Addon"
Defines caching channels and lookup.
bot = client
instance-attribute
¶
channels: dict[Snowflake, dict[Snowflake, ChannelModel]] = {}
instance-attribute
¶
channel_index: dict[Snowflake, ChannelModel] = {}
instance-attribute
¶
on_guild_create
async
¶
Append new guild channels to cache. Also add channels to index.
Parameters:
-
event(GuildCreateEvent) –the GUILD_CREATE event
on_guild_delete
async
¶
Remove guild channels from cache. Also remove channels from index
Parameters:
-
event(GuildDeleteEvent) –the GUILD_DELETE event
on_channel_create
async
¶
Append channel to guild key. Also append channel to index.
Raises:
-
MissingField–no associated guild ID
Parameters:
-
event(GuildChannelCreateEvent) –the CHANNEL_CREATE event
on_channel_update
async
¶
Replace channel in guild key. Also replace channel in index.
Raises:
-
MissingField–no associated guild ID
Parameters:
-
event(GuildChannelUpdateEvent) –the CHANNEL_UPDATE event
on_channel_delete
async
¶
Remove channel from guild key. Also remove channel from index.
Raises:
-
MissingField–no associated guild ID
Parameters:
-
event(GuildChannelDeleteEvent) –the CHANNEL_DELETE event
get_channel
async
¶
Fetch a guild channel. If not found, request and store it.
Parameters:
-
channel_id(Snowflake) –ID of channel
Returns:
-
ChannelModel | None–hydrated channel object or None if fetch failed
put
¶
Put a new channel into the cache.
Parameters:
-
channel(ChannelModel) –the channel object
Raises:
-
MissingField–no associated guild ID