-
Notifications
You must be signed in to change notification settings - Fork 3
/
structure.clj
68 lines (58 loc) · 1.78 KB
/
structure.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(ns slash.component.structure
"Functions to make component creation easier.
Read https://discord.com/developers/docs/interactions/message-components first to understand the structure of message components."
(:require [slash.util :refer [omission-map]]))
(defn action-row
"Create an action row containing other components.
See https://discord.com/developers/docs/interactions/message-components#action-rows for more info."
[& components]
{:type 1
:components components})
(defn link-button
"Create a button that links to a URL."
[url & {:keys [label emoji disabled]}]
(omission-map
:type 2
:style 5
:url url
:label label
:emoji emoji
:disabled disabled))
(def button-styles
"Map of button style names (keywords) to their numerical identifiers."
{:primary 1
:secondary 2
:success 3
:danger 4})
(defn button
"Create a regular interaction button.
See https://discord.com/developers/docs/interactions/message-components#buttons for more info."
[style custom-id & {:keys [label emoji disabled]}]
(omission-map
:type 2
:style (button-styles style)
:custom_id custom-id
:label label
:emoji emoji
:disabled disabled))
(defn select-menu
"Create a select menu.
See https://discord.com/developers/docs/interactions/message-components#select-menus for more info."
[custom-id options & {:keys [placeholder min-values max-values disabled]}]
(omission-map
:type 3
:custom_id custom-id
:options options
:placeholder placeholder
:min_values min-values
:max_values max-values
:disabled disabled))
(defn select-option
"Create an option for a select menu."
[label value & {:keys [description emoji default]}]
(omission-map
:label label
:value value
:description description
:emoji emoji
:default default))