View Source Nostrum.Cache.ChannelGuildMapping behaviour (Nostrum v0.9.0)

Cache behaviour & dispatcher for mapping channel IDs to their respective guilds.

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

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.

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.

Callbacks

Link to this callback

child_spec(term)

View Source (since 0.8.0)
@callback child_spec(term()) :: Supervisor.child_spec()

Retrieve the child specification for starting this mapping under a supervisor.

Link to this callback

create(id, id)

View Source (since 0.8.0)
@callback create(Nostrum.Struct.Channel.id(), Nostrum.Struct.Guild.id()) :: true

Create a mapping of the given channel to the given guild.

Link to this callback

delete(id)

View Source (since 0.8.0)
@callback delete(Nostrum.Struct.Channel.id()) :: true

Remove any mapping associated with the given channel.

Retrieve the guild ID for the given channel ID, if present.

Functions