View Source Nostrum.Cache.ChannelGuildMapping behaviour (Nostrum v0.8.0)
Cache behaviour & dispatcher for mapping channel IDs to their respective guilds.
purpose
Purpose
While retrieving the channels on a specific guild is trivial as they are
stored on the guild, retrieving the guild a given channel belongs to is not
possible with the regular data mode of channels. This module allows to
retrieve guilds associated with a channel via get/1
.
configuration
Configuration
By default, nostrum will use Elixir.Nostrum.Cache.ChannelGuildMapping.ETS
to store the
mapping. To override this, set the [:caches, :channel_guild_mapping]
setting on nostrum's application configuration:
config :nostrum,
caches: %{
channel_guild_mapping: MyBot.Nostrum.Cache.ChannelGuildMapping
}
This setting must be set at compile time.
Link to this section Summary
Callbacks
Retrieve the child specification for starting this mapping under a supervisor.
Create a mapping of the given channel to the given guild.
Remove any mapping associated with the given channel.
Retrieve the guild ID for the given channel ID, if present.
Link to this section Callbacks
@callback child_spec(term()) :: Supervisor.child_spec()
Retrieve the child specification for starting this mapping under a supervisor.
@callback create(Nostrum.Struct.Channel.id(), Nostrum.Struct.Guild.id()) :: true
Create a mapping of the given channel to the given guild.
@callback delete(Nostrum.Struct.Channel.id()) :: true
Remove any mapping associated with the given channel.
@callback get(Nostrum.Struct.Channel.id()) :: Nostrum.Struct.Guild.id() | nil
Retrieve the guild ID for the given channel ID, if present.