Nostrum v0.4.1 Nostrum.Cache.GuildCache 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
clause()
View Source
clause() ::
{:id, Nostrum.Struct.Guild.id()}
| {:channel_id, Nostrum.Struct.Channel.id()}
| {:message, Nostrum.Struct.Message.t()}
clause() :: {:id, Nostrum.Struct.Guild.id()} | {:channel_id, Nostrum.Struct.Channel.id()} | {:message, Nostrum.Struct.Message.t()}
clauses() View Source
reason()
View Source
reason() :: :id_not_found | :id_not_found_on_guild_lookup
reason() :: :id_not_found | :id_not_found_on_guild_lookup
selector()
View Source
selector() :: (Nostrum.Struct.Guild.t() -> any())
selector() :: (Nostrum.Struct.Guild.t() -> any())
Link to this section Functions
all()
View Source
all() :: Enum.t()
all() :: Enum.t()
Retrives all Nostrum.Struct.Guild
from the cache as a stream.
get(id)
View Source
get(Nostrum.Struct.Guild.id()) ::
{:ok, Nostrum.Struct.Guild.t()} | {:error, reason()}
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}
get!(id)
View Source
get!(Nostrum.Struct.Guild.id()) :: Nostrum.Struct.Guild.t() | no_return()
get!(Nostrum.Struct.Guild.id()) :: Nostrum.Struct.Guild.t() | no_return()
Same as get/1
, but raises Nostrum.Error.CacheError
in case of failure.
get_by(clauses)
View Source
get_by(clauses()) :: {:ok, Nostrum.Struct.Guild.t()} | {:error, reason()}
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}
get_by!(clauses)
View Source
get_by!(clauses()) :: Nostrum.Struct.Guild.t() | no_return()
get_by!(clauses()) :: Nostrum.Struct.Guild.t() | no_return()
Same as get_by/1
, but raises Nostrum.Error.CacheError
in case of failure.
select(id, selector)
View Source
select(Nostrum.Struct.Guild.id(), selector()) ::
{:ok, any()} | {:error, reason()}
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}
select!(id, selector)
View Source
select!(Nostrum.Struct.Guild.id(), selector()) :: any() | no_return()
select!(Nostrum.Struct.Guild.id(), selector()) :: any() | no_return()
Same as select/2
, but raises Nostrum.Error.CacheError
in case of failure.
select_all(selector) View Source
Selects values using a selector
from all Nostrum.Struct.Guild
in the cache.
select_by(clauses, selector) View Source
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}
select_by!(clauses, selector) View Source
Same as select_by/2
, but raises Nostrum.Error.CacheError
in case of failure.