Middleware to cache all the state that Discord sends.
Middleware to cache all the state that Discord sends.
Handler map for all state-caching events.
The state saved is of the following form:
{:discljord.events.state/bot <current-user>
:discljord.events.state/guilds {<guild-id> <guild-object>}
:discljord.events.state/users {<user-id> <user-object>}
:discljord.events.state/private-channels {<channel-id> <channel-object>}}
Guild objects are modified in a few ways. Roles, members, presences, threads and
channels are all stored as maps from id to object, and members' and presence's
user keys are the id of the user which is stored under the state's
:discljord.events.state/users
key. Any information received from
:presence-update
events is also merged into the user object, and a voice
state object is stored under :voice
.
Threads also include a map of user ids to
thread member objects in their :member
key.
Private channels are channels which lack a guild, including direct messages and group messages.
Handler map for all state-caching events. The state saved is of the following form: ```clojure {:discljord.events.state/bot <current-user> :discljord.events.state/guilds {<guild-id> <guild-object>} :discljord.events.state/users {<user-id> <user-object>} :discljord.events.state/private-channels {<channel-id> <channel-object>}} ``` Guild objects are modified in a few ways. Roles, members, presences, threads and channels are all stored as maps from id to object, and members' and presence's user keys are the id of the user which is stored under the state's `:discljord.events.state/users` key. Any information received from `:presence-update` events is also merged into the user object, and a voice state object is stored under `:voice`. Threads also include a map of user ids to [thread member objects](https://discord.com/developers/docs/resources/channel#thread-member-object) in their `:member` key. Private channels are channels which lack a guild, including direct messages and group messages.
(caching-middleware state)
(caching-middleware state caching-handlers)
Creates a middleware that caches Discord event data in state
.
state
must be an [[clojure.core/atom]] containing a map.
caching-handlers
, if provided, must be a map of event keyword -> sequence of caching handlers.
Each caching handler is a function that takes the event type, data and the state atom and updates the atom where applicable.
If this parameter is not provided, the default caching-handlers
are used.
See its docs for more information on the default cache layout and behavior.
Creates a middleware that caches Discord event data in `state`. `state` must be an [[clojure.core/atom]] containing a map. `caching-handlers`, if provided, must be a map of event keyword -> sequence of caching handlers. Each caching handler is a function that takes the event type, data and the state atom and updates the atom where applicable. If this parameter is not provided, the default [[caching-handlers]] are used. See its docs for more information on the default cache layout and behavior.
(caching-transducer state)
(caching-transducer state caching-handlers)
Creates a transducer which caches event data and passes on all events.
Values on the transducer are expected to be tuples of event-type and
event-data.
state
must be an [[clojure.core/atom]] containing a map.
caching-handlers
, if provided, must be a map of event keyword -> sequence of caching handlers.
Each caching handler is a function that takes the event type, data and the state atom and updates the atom where applicable.
If this parameter is not provided, the default caching-handlers
are used.
See its docs for more information on the default cache layout and behavior.
Creates a transducer which caches event data and passes on all events. Values on the transducer are expected to be tuples of event-type and event-data. `state` must be an [[clojure.core/atom]] containing a map. `caching-handlers`, if provided, must be a map of event keyword -> sequence of caching handlers. Each caching handler is a function that takes the event type, data and the state atom and updates the atom where applicable. If this parameter is not provided, the default [[caching-handlers]] are used. See its docs for more information on the default cache layout and behavior.
(channel-pins-update _ {:keys [guild-id channel-id last-pin-timestamp]} state)
(guild-update _ guild state)
Stores the guild into the state.
Stores the guild into the state.
(prepare-guild guild)
Takes a guild and prepares it for storing in the cache.
The roles vector will be transformed to a map keyed off if, members
transformed to a map from user id to member object with :user
key replaced
by the user id, channels will be changed to a map from id to channel object.
Takes a guild and prepares it for storing in the cache. The roles vector will be transformed to a map keyed off if, members transformed to a map from user id to member object with `:user` key replaced by the user id, channels will be changed to a map from id to channel object.
(presence-update _
{:keys [user guild-id activities status client-status]
:as presence}
state)
(ready _ {:keys [user guilds]} state)
Stores the user and guilds into the state.
Stores the user and guilds into the state.
(thread-member-update _ {:keys [guild-id id user-id] :as member} state)
(thread-members-update _
{:keys [added-members removed-member-ids id guild-id
member-count :as event]}
state)
(thread-update
_
{:keys [guild-id id] {:keys [archived]} :thread-metadata :as thread}
state)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close