Liking cljdoc? Tell your friends :D

discljord.events.middleware

Contains functions for constructing middleware, and some default middleware.

Middleware for discljord event handlers allow the modification and filtration of events to be sent along to event handlers. Following is an example of an identity middleware, and can be used as an example of what middleware in discljord look like.

(defn identity-middleware
  "Middleware that passes through events unchanged."
  [handler]
  (fn [event-type event-data & more]
    (apply handler event-type event-data more)))
Contains functions for constructing middleware, and some default middleware.

Middleware for discljord event handlers allow the modification and filtration
of events to be sent along to event handlers. Following is an example of an
identity middleware, and can be used as an example of what middleware in
discljord look like.

```clojure
(defn identity-middleware
  "Middleware that passes through events unchanged."
  [handler]
  (fn [event-type event-data & more]
    (apply handler event-type event-data more)))
```
raw docstring

concatclj

(concat handler)

Takes a handler function and creates a middleware which concats the handlers.

The events in the handler function passed are always run before the ones that are given to the middleware when it is applied.

Takes a handler function and creates a middleware which concats the handlers.

The events in the handler function passed are always run before the ones that
are given to the middleware when it is applied.
sourceraw docstring

data-mappingclj

(data-mapping f)

Makes a transform function for use with map that operates on event-data.

The resulting function is from a vector of event-type and event-data to a vector of event-type and event-data. The event-type is passed through without change, and event-data is transformed by f.

Makes a transform function for use with [[map]] that operates on event-data.

The resulting function is from a vector of event-type and event-data to a
vector of event-type and event-data. The event-type is passed through without
change, and event-data is transformed by `f`.
sourceraw docstring

filterclj

(filter pred)

Makes middleware that only calls the handler if pred returns truthy.

pred is a predicate expected to take the event-type and event-data.

Makes middleware that only calls the handler if `pred` returns truthy.

`pred` is a predicate expected to take the event-type and event-data.
sourceraw docstring

ignore-bot-messagesclj

Middleware which won't call the handler if the event is a message from a bot.

Middleware which won't call the handler if the event is a message from a bot.
sourceraw docstring

log-whenclj

(log-when filter)

Takes a predicate and if it returns true, logs the event before passing it on.

The predicate must take the event-type and the event-data, and return a truthy value if it should log. If the value is a valid level at which to log, that logging level will be used.

Takes a predicate and if it returns true, logs the event before passing it on.

The predicate must take the event-type and the event-data, and return a truthy
value if it should log. If the value is a valid level at which to log, that
logging level will be used.
sourceraw docstring

mapclj

(map f)

Makes a middleware which runs f over events before passing to the handler.

f is a function of a vector of event-type and event-data to a vector of event-type and event-data which are then passed to the handler.

Makes a middleware which runs `f` over events before passing to the handler.

`f` is a function of a vector of event-type and event-data to a vector of
event-type and event-data which are then passed to the handler.
sourceraw docstring

transduceclj

(transduce xf)

Makes a middleware which takes a transducer and runs it over event-data.

Makes a middleware which takes a transducer and runs it over event-data.
sourceraw docstring

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

× close