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-handlersclj

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

caching-middlewareclj

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

caching-transducerclj

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

prepare-threadclj

(prepare-thread {:keys [member] :as thread})
source

presence-updateclj

(presence-update _
                 {:keys [user guild-id activities status client-status]
                  :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

thread-deleteclj

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

thread-list-syncclj

(thread-list-sync _ {:keys [guild-id channel-ids threads members]} state)
source

thread-member-updateclj

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

thread-members-updateclj

(thread-members-update _
                       {:keys [added-members removed-member-ids id guild-id
                               member-count :as event]}
                       state)
source

thread-updateclj

(thread-update
  _
  {:keys [guild-id id] {:keys [archived]} :thread-metadata :as thread}
  state)
source

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