-
Notifications
You must be signed in to change notification settings - Fork 3
/
core.clj
21 lines (16 loc) · 872 Bytes
/
core.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(ns slash.core
"Core namespace.")
(def interaction-types
"A map of interaction type code -> interaction type name keyword.
See https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type"
{1 :ping
2 :application-command
3 :message-component})
(defn route-interaction
"Takes a handler map and an interaction and routes the interaction to the correct handler.
The handler map should map each interaction type to one handler function.
The handler functions take the interaction as a parameter.
See [[slash.gateway/gateway-defaults]] and [[slash.webhook/webhook-defaults]] for default handler maps.
The interaction object passed to this function must be given as a Clojure map with keywords as keys."
[handlers {:keys [type] :as interaction}]
((-> type interaction-types handlers) interaction))