Nostrum.Cache.GuildCache (Nostrum v0.4.6) View Source
Functions for retrieving guild states.
Link to this section Summary
Functions
Retrives all Nostrum.Struct.Guild
from the cache as a stream.
Retrives a single Nostrum.Struct.Guild
from the cache via its id
.
Same as get/1
, but raises Nostrum.Error.CacheError
in case of failure.
Retrives a single Nostrum.Struct.Guild
where it matches the clauses
.
Same as get_by/1
, but raises Nostrum.Error.CacheError
in case of failure.
Selects values using a selector
from a Nostrum.Struct.Guild
.
Same as select/2
, but raises Nostrum.Error.CacheError
in case of failure.
Selects values using a selector
from all Nostrum.Struct.Guild
in the cache.
Selects values using a selector
from a Nostrum.Struct.Guild
that matches
the clauses
.
Same as select_by/2
, but raises Nostrum.Error.CacheError
in case of failure.
Link to this section Types
Specs
clause() :: {:id, Nostrum.Struct.Guild.id()} | {:channel_id, Nostrum.Struct.Channel.id()} | {:message, Nostrum.Struct.Message.t()}
Specs
Specs
reason() :: :id_not_found | :id_not_found_on_guild_lookup
Specs
selector() :: (Nostrum.Struct.Guild.t() -> any())
Link to this section Functions
Specs
all() :: Enum.t()
Retrives all Nostrum.Struct.Guild
from the cache as a stream.
Specs
get(Nostrum.Struct.Guild.id()) :: {:ok, Nostrum.Struct.Guild.t()} | {:error, reason()}
Retrives a single Nostrum.Struct.Guild
from the cache via its id
.
Returns {:error, reason}
if no result was found.
Examples
iex> Nostrum.Cache.GuildCache.get(0)
{:ok, %Nostrum.Struct.Guild{id: 0}}
iex> Nostrum.Cache.GuildCache.get(10)
{:error, :id_not_found_on_guild_lookup}
Specs
get!(Nostrum.Struct.Guild.id()) :: Nostrum.Struct.Guild.t() | no_return()
Same as get/1
, but raises Nostrum.Error.CacheError
in case of failure.
Specs
get_by(clauses()) :: {:ok, Nostrum.Struct.Guild.t()} | {:error, reason()}
Retrives a single Nostrum.Struct.Guild
where it matches the clauses
.
Returns {:error, reason}
if no result was found.
iex> Nostrum.Cache.GuildCache.get_by(id: 0)
{:ok, %Nostrum.Struct.Guild{id: 0}}
iex> Nostrum.Cache.GuildCache.get_by(%{id: 0})
{:ok, %Nostrum.Struct.Guild{id: 0}}
iex> Nostrum.Cache.GuildCache.get_by(id: 10)
{:error, :id_not_found_on_guild_lookup}
Specs
get_by!(clauses()) :: Nostrum.Struct.Guild.t() | no_return()
Same as get_by/1
, but raises Nostrum.Error.CacheError
in case of failure.
Specs
select(Nostrum.Struct.Guild.id(), selector()) :: {:ok, any()} | {:error, reason()}
Selects values using a selector
from a Nostrum.Struct.Guild
.
Returns {:error, reason}
if no result was found.
Examples
iex> Nostrum.Cache.GuildCache.select(0, fn guild -> guild.id end)
{:ok, 0}
iex> Nostrum.Cache.GuildCache.select(10, fn guild -> guild.id end)
{:error, :id_not_found_on_guild_lookup}
Specs
select!(Nostrum.Struct.Guild.id(), selector()) :: any() | no_return()
Same as select/2
, but raises Nostrum.Error.CacheError
in case of failure.
Specs
Selects values using a selector
from all Nostrum.Struct.Guild
in the cache.
Specs
Selects values using a selector
from a Nostrum.Struct.Guild
that matches
the clauses
.
Returns {:error, reason}
if no result was found.
iex> Nostrum.Cache.GuildCache.select_by([id: 0], fn guild -> guild.id end)
{:ok, 0}
iex> Nostrum.Cache.GuildCache.select_by(%{id: 0}, fn guild -> guild.id end)
{:ok, 0}
iex> Nostrum.Cache.GuildCache.select_by([id: 10], fn guild -> guild.id end)
{:error, :id_not_found_on_guild_lookup}
Specs
Same as select_by/2
, but raises Nostrum.Error.CacheError
in case of failure.