View Source Nostrum.Store.UnavailableGuild behaviour (Nostrum v0.10.0)
Behaviour & dispatcher for storing unavailable guilds.
Purpose
The GUILD_CREATE
gateway event on its own provides no means to determine
whether the guild we receive is a guild that the bot joined, or a guild that
has just become available over the gateway. To work around this, this store
keeps track of unavailable guilds we received to determine whether a guild
sent over this event is unavailable or new. It is therefore unlikely this
module needs to be used outside of nostrum.
Configuration
By default, nostrum will use Elixir.Nostrum.Store.UnavailableGuild.ETS
to store
unavailable guilds. To override this, set the [:stores, :unavailable_guilds]
setting on nostrum's application configuration:
config :nostrum,
stores: %{
unavailable_guilds: MyBot.Nostrum.Store.UnavailableGuild
}
This setting must be set at compile time.
Implementation
If implementing your own unavailable guild store, in addition to the
callbacks of this module, you must also provide the function child_spec/1
.
The recommended approach is to spawn a Supervisor
to manage your store.
Summary
Callbacks
Retrieve the child specification for starting this mapping under a supervisor.
Mark the given guild as unavailable.
Return whether the guild is unavailable.
Callbacks
@callback child_spec(term()) :: Supervisor.child_spec()
Retrieve the child specification for starting this mapping under a supervisor.
@callback create(Nostrum.Struct.Guild.id()) :: :ok
Mark the given guild as unavailable.
@callback is?(Nostrum.Struct.Guild.id()) :: boolean()
Return whether the guild is unavailable.