Liking cljdoc? Tell your friends :D

discljord.events.state

Middleware to cache all the state that Discord sends.

Middleware to cache all the state that Discord sends.
raw docstring

caching-middlewareclj

(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.
sourceraw docstring

caching-transducerclj

(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]].
sourceraw docstring

channel-deleteclj

(channel-delete _ channel state)
source

channel-pins-updateclj

(channel-pins-update _ {:keys [guild-id channel-id last-pin-timestamp]} state)
source

channel-updateclj

(channel-update _ channel state)
source

guild-emojis-updateclj

(guild-emojis-update _ {:keys [guild-id emojis]} state)
source

guild-member-removeclj

(guild-member-remove _ {:keys [guild-id user]} state)
source

guild-member-updateclj

(guild-member-update _ {:keys [guild-id user] :as member} state)
source

guild-members-chunkclj

(guild-members-chunk _ {:keys [guild-id members]} state)
source

guild-role-deleteclj

(guild-role-delete _ {:keys [guild-id role-id]} state)
source

guild-role-updateclj

(guild-role-update _ {:keys [guild-id role]} state)
source

guild-updateclj

(guild-update _ guild state)

Stores the guild into the state.

Stores the guild into the state.
sourceraw docstring

message-createclj

(message-create _ {:keys [guild-id channel-id id]} state)
source

prepare-guildclj

(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.
sourceraw docstring

presence-updateclj

(presence-update _ {:keys [user guild-id roles nick] :as presence} state)
source

readyclj

(ready _ {:keys [user guilds]} state)

Stores the user and guilds into the state.

Stores the user and guilds into the state.
sourceraw docstring

user-updateclj

(user-update _ user state)
source

voice-state-updateclj

(voice-state-update _ {:keys [user-id] :as voice} state)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close