Middleware to cache all the state that Discord sends.
Middleware to cache all the state that Discord sends.
(caching-middleware state)
Creates a middleware that caches all Discord event data in state
.
state
must be an [[clojure.core/atom]] containing a map.
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, 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
.
Private channels are channels which lack a guild, including direct messages and group messages.
Creates a middleware that caches all Discord event data in `state`. `state` must be an [[clojure.core/atom]] containing a map. 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, 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`. Private channels are channels which lack a guild, including direct messages and group messages.
(caching-transducer state)
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.
Saved state is identical to caching-middleware
.
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. Saved state is identical to [[caching-middleware]].
(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.
(ready _ {:keys [user guilds]} state)
Stores the user and guilds into the state.
Stores the user and guilds into the state.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close