Nosedrum.MessageCache behaviour (nosedrum v0.6.0) View Source
A cache for recent messages sent on guilds.
Usage of implementations of this module is useful when your bot needs to access recently sent messages without hogging the API. One use case would be bots with an integrated mod log that want to show a before & after comparison of edited messages.
Link to this section Summary
Callbacks
Consume the given message
in the cache process identified by cache
.
Retrieve a single message for the given guild_id
with the specified message_id
from the cache process identified by cache
.
Retrieve up to limit
messages for the given guild_id
from the cache
process identified by cache
. If limit
is :infinity
, return all
messages for that guild from the cache.
Update the given message
in the cache, if present.
Link to this section Callbacks
Specs
consume(message :: Nostrum.Struct.Message.t(), cache :: any()) :: any()
Consume the given message
in the cache process identified by cache
.
Whether this is done asynchronously or synchronously depends on the implementation.
Specs
get( guild_id :: Nostrum.Struct.Guild.id(), message_id :: Nostrum.Struct.Message.id(), cache :: any() ) :: Nostrum.Struct.Message.t() | nil | {:error, String.t()}
Retrieve a single message for the given guild_id
with the specified message_id
from the cache process identified by cache
.
If no message with the given ID is cached, nil
is returned.
Specs
recent_in_guild( guild_id :: Nostrum.Struct.Guild.id(), limit :: pos_integer() | :infinity, cache :: any() ) :: [Nostrum.Struct.Message.t()]
Retrieve up to limit
messages for the given guild_id
from the cache
process identified by cache
. If limit
is :infinity
, return all
messages for that guild from the cache.
If the guild is not cached, an empty message list is returned.
Specs
update(message :: Nostrum.Struct.Message.t(), cache :: any()) :: any()
Update the given message
in the cache, if present.
Whether this is done asynchronously or synchronously depends on the implementation.