discordrb-webhooks 3.7.2 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/discordrb/webhooks/modal.rb +231 -31
- data/lib/discordrb/webhooks/version.rb +1 -1
- data/lib/discordrb/webhooks/view.rb +315 -35
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d59a6fd132ccdb647c4e1de2ea5f622812214b405b0b3a0238d572f3459e7d9
|
|
4
|
+
data.tar.gz: 0cf571b8db5c1c564cfd27ead9c68a027765829cc26434632b6f8fcca180f698
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f07cb9c9190b1d1123fc7b7f7683eef2baf4881a027413de00665918e3540748bd7018836f5a06f027b8c56940d7ab85d90eaa2a43b96b5c046fdadcca09525
|
|
7
|
+
data.tar.gz: 2bbe3e0c5c366f387ab65ad233f680da8e9cb3144f4a4b07d1efc3bf432651d90a1f2c3b9d873bb96ca0c33431e219d2801c03861c587559496843736b21e76a
|
|
@@ -5,76 +5,276 @@ class Discordrb::Webhooks::Modal
|
|
|
5
5
|
# A mapping of names to types of components usable in a modal.
|
|
6
6
|
COMPONENT_TYPES = {
|
|
7
7
|
action_row: 1,
|
|
8
|
-
|
|
8
|
+
string_select: 3,
|
|
9
|
+
text_input: 4,
|
|
10
|
+
user_select: 5,
|
|
11
|
+
role_select: 6,
|
|
12
|
+
mentionable_select: 7,
|
|
13
|
+
channel_select: 8,
|
|
14
|
+
text_display: 10,
|
|
15
|
+
label: 18,
|
|
16
|
+
file_upload: 19,
|
|
17
|
+
radio_group: 21,
|
|
18
|
+
checkbox_group: 22,
|
|
19
|
+
checkbox: 23
|
|
9
20
|
}.freeze
|
|
10
21
|
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
# Builder for radio and checkbox groups.
|
|
23
|
+
class GroupBuilder
|
|
24
|
+
# @!visibility private
|
|
25
|
+
def initialize(type, custom_id, id, options = [], required = nil, min_values = nil, max_values = nil)
|
|
26
|
+
@id = id
|
|
27
|
+
@type = type
|
|
28
|
+
@custom_id = custom_id
|
|
29
|
+
@options = options
|
|
30
|
+
@required = required
|
|
31
|
+
@min_values = min_values
|
|
32
|
+
@max_values = max_values
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Add a checkbox component to the group.
|
|
36
|
+
# @param value [String] The value that the checkbox represents.
|
|
37
|
+
# @param label [String] The primary text of the checkbox.
|
|
38
|
+
# @param description [String, nil] The description of the checkbox.
|
|
39
|
+
# @param default [true, false, nil] Whether or not the checkbox should be checked by default.
|
|
40
|
+
def checkbox(value:, label:, description: nil, default: nil)
|
|
41
|
+
raise "Cannot add a checkbox to a #{@type}" unless @type == :checkbox_group
|
|
42
|
+
|
|
43
|
+
@options << { value: value, label: label, description: description, default: default }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Add a radio button component to the group.
|
|
47
|
+
# @param value [String] The value that the radio button represents.
|
|
48
|
+
# @param label [String] The primary text of the radio button.
|
|
49
|
+
# @param description [String, nil] The description of the radio button.
|
|
50
|
+
# @param default [true, false, nil] Whether or not the radio button should be selected by default.
|
|
51
|
+
def radio_button(value:, label:, description: nil, default: nil)
|
|
52
|
+
raise "Cannot add a radio button to a #{@type}" unless @type == :radio_group
|
|
53
|
+
|
|
54
|
+
@options << { value: value, label: label, description: description, default: default }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
alias_method :button, :radio_button
|
|
58
|
+
|
|
59
|
+
# @!visibility private
|
|
60
|
+
def to_h
|
|
61
|
+
{
|
|
62
|
+
id: @id,
|
|
63
|
+
type: COMPONENT_TYPES[@type],
|
|
64
|
+
custom_id: @custom_id,
|
|
65
|
+
options: @options.map(&:to_h),
|
|
66
|
+
required: @required,
|
|
67
|
+
min_values: @min_values,
|
|
68
|
+
max_values: @max_values
|
|
69
|
+
}.compact
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# This builder is used when adding a label component to a modal.
|
|
74
|
+
class LabelBuilder
|
|
75
|
+
# A mapping of text input styles to symbol names. `short` is a single line where `paragraph` is a block.
|
|
16
76
|
TEXT_INPUT_STYLES = {
|
|
17
77
|
short: 1,
|
|
18
78
|
paragraph: 2
|
|
19
79
|
}.freeze
|
|
20
80
|
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
|
|
81
|
+
# Create a label component.
|
|
82
|
+
# @param label [String, nil] The label of the label component. This
|
|
83
|
+
# field should always be passed, and will be required in 4.0.
|
|
84
|
+
# @param id [Integer, nil] The unique 32-bit ID of the label component.
|
|
85
|
+
# @param description [String, nil] The description of the label component.
|
|
86
|
+
# @yieldparam builder [LabelBuilder] Yields the initialized label component.
|
|
87
|
+
def initialize(label: nil, id: nil, description: nil)
|
|
88
|
+
@id = id
|
|
89
|
+
@label = label
|
|
90
|
+
@description = description
|
|
91
|
+
|
|
92
|
+
yield self if block_given?
|
|
24
93
|
end
|
|
25
94
|
|
|
26
|
-
# Add a text input to
|
|
95
|
+
# Add a text input to the label component.
|
|
27
96
|
# @param style [Symbol, Integer] The text input's style type. See {TEXT_INPUT_STYLES}
|
|
28
97
|
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
29
98
|
# There is a limit of 100 characters to each custom_id.
|
|
30
|
-
# @param
|
|
99
|
+
# @param id [Integer] The integer ID for this component. This is not to be confused with custom_id.
|
|
31
100
|
# @param min_length [Integer, nil] The minimum input length for a text input, min 0, max 4000.
|
|
32
101
|
# @param max_length [Integer, nil] The maximum input length for a text input, min 1, max 4000.
|
|
33
102
|
# @param required [true, false, nil] Whether this component is required to be filled, default true.
|
|
34
103
|
# @param value [String, nil] A pre-filled value for this component, max 4000 characters.
|
|
35
104
|
# @param placeholder [String, nil] Custom placeholder text if the input is empty, max 100 characters
|
|
36
|
-
|
|
37
|
-
|
|
105
|
+
# @param label [String, nil] This parameter is deprecated and will be removed soon. Please pass this argument to {LabelBuilder#initialize} instead.
|
|
106
|
+
def text_input(style:, custom_id:, id: nil, min_length: nil, max_length: nil, required: nil, value: nil, placeholder: nil, label: nil)
|
|
107
|
+
@label = label unless label.nil?
|
|
38
108
|
|
|
39
|
-
@
|
|
40
|
-
|
|
109
|
+
@component = {
|
|
110
|
+
id: id,
|
|
111
|
+
style: TEXT_INPUT_STYLES[style] || style,
|
|
41
112
|
custom_id: custom_id,
|
|
42
113
|
type: COMPONENT_TYPES[:text_input],
|
|
43
|
-
label: label,
|
|
44
114
|
min_length: min_length,
|
|
45
115
|
max_length: max_length,
|
|
46
116
|
required: required,
|
|
47
117
|
value: value,
|
|
48
118
|
placeholder: placeholder
|
|
49
|
-
}
|
|
119
|
+
}.compact
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Add a string select menu to the label component.
|
|
123
|
+
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
124
|
+
# There is a limit of 100 characters to each custom_id.
|
|
125
|
+
# @param id [Integer, nil] The unique 32-bit ID of the string select. This is not to be confused with the `custom_id`.
|
|
126
|
+
# @param options [Array<Hash>] Options that can be selected in this menu. Can also be provided via the yielded builder.
|
|
127
|
+
# @param placeholder [String, nil] Default text to show when no entries are selected.
|
|
128
|
+
# @param min_values [Integer, nil] The minimum amount of values a user must select.
|
|
129
|
+
# @param max_values [Integer, nil] The maximum amount of values a user can select.
|
|
130
|
+
# @param required [true, false, nil] Whether a value must be selected for the component.
|
|
131
|
+
# @yieldparam builder [SelectMenuBuilder] The select menu builder is yielded to allow for the modification of attributes.
|
|
132
|
+
def string_select(custom_id:, id: nil, options: [], placeholder: nil, min_values: nil, max_values: nil, required: nil)
|
|
133
|
+
builder = Discordrb::Webhooks::View::SelectMenuBuilder.new(custom_id, options, placeholder, min_values, max_values, nil, select_type: :string_select, id: id, required: required)
|
|
134
|
+
|
|
135
|
+
yield builder if block_given?
|
|
136
|
+
|
|
137
|
+
@component = builder.to_h
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
alias_method :select_menu, :string_select
|
|
141
|
+
|
|
142
|
+
# Add a select user to the label component.
|
|
143
|
+
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
144
|
+
# There is a limit of 100 characters to each custom_id.
|
|
145
|
+
# @param id [Integer, nil] The unique 32-bit ID of the user select. This is not to be confused with the `custom_id`.
|
|
146
|
+
# @param placeholder [String, nil] Default text to show when no entries are selected.
|
|
147
|
+
# @param min_values [Integer, nil] The minimum amount of values a user must select.
|
|
148
|
+
# @param max_values [Integer, nil] The maximum amount of values a user can select.
|
|
149
|
+
# @param required [true, false, nil] Whether a value must be selected for the component.
|
|
150
|
+
def user_select(custom_id:, id: nil, placeholder: nil, min_values: nil, max_values: nil, required: nil)
|
|
151
|
+
@component = Discordrb::Webhooks::View::SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, nil, select_type: :user_select, id: id, required: required).to_h
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Add a select role to the label component.
|
|
155
|
+
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
156
|
+
# There is a limit of 100 characters to each custom_id.
|
|
157
|
+
# @param id [Integer, nil] The unique 32-bit ID of the role select. This is not to be confused with the `custom_id`.
|
|
158
|
+
# @param placeholder [String, nil] Default text to show when no entries are selected.
|
|
159
|
+
# @param min_values [Integer, nil] The minimum amount of values a user must select.
|
|
160
|
+
# @param max_values [Integer, nil] The maximum amount of values a user can select.
|
|
161
|
+
# @param required [true, false, nil] Whether a value must be selected for the component.
|
|
162
|
+
def role_select(custom_id:, id: nil, placeholder: nil, min_values: nil, max_values: nil, required: nil)
|
|
163
|
+
@component = Discordrb::Webhooks::View::SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, nil, select_type: :role_select, id: id, required: required).to_h
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Add a select mentionable to the label component.
|
|
167
|
+
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
168
|
+
# There is a limit of 100 characters to each custom_id.
|
|
169
|
+
# @param id [Integer, nil] The unique 32-bit ID of the mentionable select. This is not to be confused with the `custom_id`.
|
|
170
|
+
# @param placeholder [String, nil] Default text to show when no entries are selected.
|
|
171
|
+
# @param min_values [Integer, nil] The minimum amount of values a user must select.
|
|
172
|
+
# @param max_values [Integer, nil] The maximum amount of values a user can select.
|
|
173
|
+
# @param required [true, false, nil] Whether a value must be selected for the component.
|
|
174
|
+
def mentionable_select(custom_id:, id: nil, placeholder: nil, min_values: nil, max_values: nil, required: nil)
|
|
175
|
+
@component = Discordrb::Webhooks::View::SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, nil, select_type: :mentionable_select, id: id, required: required).to_h
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Add a select channel to the label component.
|
|
179
|
+
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
180
|
+
# There is a limit of 100 characters to each custom_id.
|
|
181
|
+
# @param id [Integer, nil] The unique 32-bit ID of the channel select. This is not to be confused with the `custom_id`.
|
|
182
|
+
# @param placeholder [String, nil] Default text to show when no entries are selected.
|
|
183
|
+
# @param min_values [Integer, nil] The minimum amount of values a user must select.
|
|
184
|
+
# @param max_values [Integer, nil] The maximum amount of values a user can select.
|
|
185
|
+
# @param required [true, false, nil] Whether a value must be selected for the component.
|
|
186
|
+
# @param types [Array<Symbol, Integer>, nil] The channel types to include in the select menu.
|
|
187
|
+
def channel_select(custom_id:, id: nil, placeholder: nil, min_values: nil, max_values: nil, required: nil, types: nil)
|
|
188
|
+
builder = Discordrb::Webhooks::View::SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, nil, select_type: :channel_select, id: id, required: required).to_h
|
|
189
|
+
|
|
190
|
+
builder[:channel_types] = types.map { |type| Discordrb::Channel::TYPES[type] || type } if types
|
|
191
|
+
|
|
192
|
+
@component = builder
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Add a file upload component to the label component.
|
|
196
|
+
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
197
|
+
# There is a limit of 100 characters to each custom_id.
|
|
198
|
+
# @param id [Integer, nil] The unique 32-bit ID of the file upload component. This is not to be confused with the `custom_id`.
|
|
199
|
+
# @param min_values [Integer, nil] The minimum amount of files a user must upload.
|
|
200
|
+
# @param max_values [Integer, nil] The maximum amount of files a user has to upload.
|
|
201
|
+
# @param required [true, false, nil] Whether or not a file must be uploaded to the component.
|
|
202
|
+
def file_upload(custom_id:, id: nil, min_values: nil, max_values: nil, required: nil)
|
|
203
|
+
@component = { type: COMPONENT_TYPES[:file_upload], custom_id: custom_id, id: id, min_values: min_values, max_values: max_values, required: required }.compact
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Add a standalone checkbox component to the label component.
|
|
207
|
+
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
208
|
+
# There is a limit of 100 characters to each custom_id.
|
|
209
|
+
# @param id [Integer, nil] The unique 32-bit ID of the checkbox component. This is not to be confused with the `custom_id`.
|
|
210
|
+
# @param default [true, false, nil] Whether or not the checkbox is checked by default.
|
|
211
|
+
def checkbox(custom_id:, id: nil, default: false)
|
|
212
|
+
@component = { type: COMPONENT_TYPES[:checkbox], custom_id: custom_id, id: id, default: default }.compact
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Add a group of radio buttons to the label component.
|
|
216
|
+
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
217
|
+
# There is a limit of 100 characters to each custom_id.
|
|
218
|
+
# @param id [Integer, nil] The unique 32-bit ID of the radio group component. This is not to be confused with the `custom_id`.
|
|
219
|
+
# @param buttons [Array<Hash>] Radio buttons for the group. Can also be provided via the yielded builder.
|
|
220
|
+
# @param required [true, false, nil] Whether or not a radio button in the group must be selected.
|
|
221
|
+
def radio_group(custom_id:, id: nil, buttons: [], required: nil)
|
|
222
|
+
builder = GroupBuilder.new(:radio_group, custom_id, id, buttons, required)
|
|
223
|
+
|
|
224
|
+
yield builder if block_given?
|
|
225
|
+
|
|
226
|
+
@component = builder.to_h
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# Add a group of checkboxes to the label component.
|
|
230
|
+
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
231
|
+
# There is a limit of 100 characters to each custom_id.
|
|
232
|
+
# @param id [Integer, nil] The unique 32-bit ID of the checkbox group component. This is not to be confused with the `custom_id`.
|
|
233
|
+
# @param checkboxes [Array<Hash>] Checkboxes for the group. Can also be provided via the yielded builder.
|
|
234
|
+
# @param min_values [Integer, nil] The minimum number of checkboxes a user must check.
|
|
235
|
+
# @param max_values [Integer, nil] The maximum number of checkboxes a user is allowed to check.
|
|
236
|
+
# @param required [true, false, nil] Whether or not a checkbox must be checked.
|
|
237
|
+
def checkbox_group(custom_id:, id: nil, checkboxes: [], min_values: nil, max_values: nil, required: nil)
|
|
238
|
+
builder = GroupBuilder.new(:checkbox_group, custom_id, id, checkboxes, required, min_values, max_values)
|
|
239
|
+
|
|
240
|
+
yield builder if block_given?
|
|
241
|
+
|
|
242
|
+
@component = builder.to_h
|
|
50
243
|
end
|
|
51
244
|
|
|
52
245
|
# @!visibility private
|
|
53
246
|
def to_h
|
|
54
|
-
{ type: COMPONENT_TYPES[:
|
|
247
|
+
{ type: COMPONENT_TYPES[:label], label: @label, description: @description, component: @component }.compact
|
|
55
248
|
end
|
|
56
249
|
end
|
|
57
250
|
|
|
58
|
-
|
|
59
|
-
|
|
251
|
+
# @!visibility private
|
|
60
252
|
def initialize
|
|
61
|
-
@
|
|
253
|
+
@components = []
|
|
62
254
|
|
|
63
255
|
yield self if block_given?
|
|
64
256
|
end
|
|
65
257
|
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
yield new_row
|
|
258
|
+
# @!visibility private
|
|
259
|
+
def to_a
|
|
260
|
+
@components.map(&:to_h)
|
|
261
|
+
end
|
|
72
262
|
|
|
73
|
-
|
|
263
|
+
# Add a label component to the view.
|
|
264
|
+
# @see LabelBuilder#initialize
|
|
265
|
+
def label(...)
|
|
266
|
+
@components << LabelBuilder.new(...)
|
|
74
267
|
end
|
|
75
268
|
|
|
76
|
-
#
|
|
77
|
-
|
|
78
|
-
|
|
269
|
+
# Add a text display component to the view.
|
|
270
|
+
# @see Webhooks::View::TextDisplayBuilder#initialize
|
|
271
|
+
def text_display(...)
|
|
272
|
+
@components << Discordrb::Webhooks::View::TextDisplayBuilder.new(...)
|
|
79
273
|
end
|
|
274
|
+
|
|
275
|
+
# @deprecated Please use {#label} instead.
|
|
276
|
+
alias_method :row, :label
|
|
277
|
+
|
|
278
|
+
# @deprecated This alias will be removed in future releases.
|
|
279
|
+
RowBuilder = LabelBuilder
|
|
80
280
|
end
|
|
@@ -11,8 +11,14 @@ class Discordrb::Webhooks::View
|
|
|
11
11
|
link: 5
|
|
12
12
|
}.freeze
|
|
13
13
|
|
|
14
|
+
# Possible separator size names and values.
|
|
15
|
+
SEPARATOR_SIZES = {
|
|
16
|
+
small: 1,
|
|
17
|
+
large: 2
|
|
18
|
+
}.freeze
|
|
19
|
+
|
|
14
20
|
# Component types.
|
|
15
|
-
# @see https://discord.com/developers/docs/
|
|
21
|
+
# @see https://discord.com/developers/docs/components/reference#component-object-component-types
|
|
16
22
|
COMPONENT_TYPES = {
|
|
17
23
|
action_row: 1,
|
|
18
24
|
button: 2,
|
|
@@ -21,28 +27,44 @@ class Discordrb::Webhooks::View
|
|
|
21
27
|
user_select: 5,
|
|
22
28
|
role_select: 6,
|
|
23
29
|
mentionable_select: 7,
|
|
24
|
-
channel_select: 8
|
|
30
|
+
channel_select: 8,
|
|
31
|
+
section: 9,
|
|
32
|
+
text_display: 10,
|
|
33
|
+
thumbnail: 11,
|
|
34
|
+
media_gallery: 12,
|
|
35
|
+
file: 13,
|
|
36
|
+
separator: 14,
|
|
37
|
+
container: 17
|
|
38
|
+
# label: 18, # (defined in modal.rb)
|
|
39
|
+
# file_upload: 19, (defined in modal.rb)
|
|
40
|
+
# radio_group: 21, (defined in modal.rb)
|
|
41
|
+
# checkbox_group: 22, (defined in modal.rb)
|
|
42
|
+
# checkbox: 23 (defined in modal.rb)
|
|
25
43
|
}.freeze
|
|
26
44
|
|
|
27
|
-
# This builder is used when constructing an ActionRow.
|
|
28
|
-
# change in the future. A message can have
|
|
45
|
+
# This builder is used when constructing an ActionRow. Button and select menu components must be within an action row, but this can
|
|
46
|
+
# change in the future. A message can have 10 action rows, each action row can hold a weight of 5. Buttons have a weight of 1,
|
|
29
47
|
# and dropdowns have a weight of 5.
|
|
30
48
|
class RowBuilder
|
|
31
49
|
# @!visibility private
|
|
32
|
-
def initialize
|
|
50
|
+
def initialize(id: nil)
|
|
51
|
+
@id = id
|
|
33
52
|
@components = []
|
|
53
|
+
|
|
54
|
+
yield self if block_given?
|
|
34
55
|
end
|
|
35
56
|
|
|
36
57
|
# Add a button to this action row.
|
|
37
58
|
# @param style [Symbol, Integer] The button's style type. See {BUTTON_STYLES}
|
|
59
|
+
# @param id [Integer, nil] The unique 32-bit ID of the button component. This is not to be confused with the `custom_id`.
|
|
38
60
|
# @param label [String, nil] The text label for the button. Either a label or emoji must be provided.
|
|
39
|
-
# @param emoji [#to_h, String, Integer] An emoji ID, or unicode emoji to attach to the button. Can also be
|
|
61
|
+
# @param emoji [#to_h, String, Integer] An emoji ID, or unicode emoji to attach to the button. Can also be an object
|
|
40
62
|
# that responds to `#to_h` which returns a hash in the format of `{ id: Integer, name: string }`.
|
|
41
63
|
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
42
64
|
# There is a limit of 100 characters to each custom_id.
|
|
43
65
|
# @param disabled [true, false] Whether this button is disabled and shown as greyed out.
|
|
44
66
|
# @param url [String, nil] The URL, when using a link style button.
|
|
45
|
-
def button(style:, label: nil, emoji: nil, custom_id: nil, disabled: nil, url: nil)
|
|
67
|
+
def button(style:, id: nil, label: nil, emoji: nil, custom_id: nil, disabled: nil, url: nil)
|
|
46
68
|
style = BUTTON_STYLES[style] || style
|
|
47
69
|
|
|
48
70
|
emoji = case emoji
|
|
@@ -52,20 +74,21 @@ class Discordrb::Webhooks::View
|
|
|
52
74
|
emoji&.to_h
|
|
53
75
|
end
|
|
54
76
|
|
|
55
|
-
@components << { type: COMPONENT_TYPES[:button], label: label, emoji: emoji, style: style, custom_id: custom_id, disabled: disabled, url: url }
|
|
77
|
+
@components << { type: COMPONENT_TYPES[:button], id: id, label: label, emoji: emoji, style: style, custom_id: custom_id, disabled: disabled, url: url }.compact
|
|
56
78
|
end
|
|
57
79
|
|
|
58
|
-
# Add a select
|
|
80
|
+
# Add a string select to this action row.
|
|
59
81
|
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
60
82
|
# There is a limit of 100 characters to each custom_id.
|
|
83
|
+
# @param id [Integer, nil] The unique 32-bit ID of the string select. This is not to be confused with the `custom_id`.
|
|
61
84
|
# @param options [Array<Hash>] Options that can be selected in this menu. Can also be provided via the yielded builder.
|
|
62
85
|
# @param placeholder [String, nil] Default text to show when no entries are selected.
|
|
63
86
|
# @param min_values [Integer, nil] The minimum amount of values a user must select.
|
|
64
87
|
# @param max_values [Integer, nil] The maximum amount of values a user can select.
|
|
65
88
|
# @param disabled [true, false, nil] Grey out the component to make it unusable.
|
|
66
89
|
# @yieldparam builder [SelectMenuBuilder]
|
|
67
|
-
def string_select(custom_id:, options: [], placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
|
|
68
|
-
builder = SelectMenuBuilder.new(custom_id, options, placeholder, min_values, max_values, disabled, select_type: :string_select)
|
|
90
|
+
def string_select(custom_id:, options: [], id: nil, placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
|
|
91
|
+
builder = SelectMenuBuilder.new(custom_id, options, placeholder, min_values, max_values, disabled, select_type: :string_select, id: id)
|
|
69
92
|
|
|
70
93
|
yield builder if block_given?
|
|
71
94
|
|
|
@@ -77,57 +100,67 @@ class Discordrb::Webhooks::View
|
|
|
77
100
|
# Add a select user to this action row.
|
|
78
101
|
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
79
102
|
# There is a limit of 100 characters to each custom_id.
|
|
103
|
+
# @param id [Integer, nil] The unique 32-bit ID of the user select. This is not to be confused with the `custom_id`.
|
|
80
104
|
# @param placeholder [String, nil] Default text to show when no entries are selected.
|
|
81
105
|
# @param min_values [Integer, nil] The minimum amount of values a user must select.
|
|
82
106
|
# @param max_values [Integer, nil] The maximum amount of values a user can select.
|
|
83
107
|
# @param disabled [true, false, nil] Grey out the component to make it unusable.
|
|
84
|
-
def user_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
|
|
85
|
-
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :user_select).to_h
|
|
108
|
+
def user_select(custom_id:, id: nil, placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
|
|
109
|
+
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :user_select, id: id).to_h
|
|
86
110
|
end
|
|
87
111
|
|
|
88
112
|
# Add a select role to this action row.
|
|
89
113
|
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
90
114
|
# There is a limit of 100 characters to each custom_id.
|
|
115
|
+
# @param id [Integer, nil] The unique 32-bit ID of the role select. This is not to be confused with the `custom_id`.
|
|
91
116
|
# @param placeholder [String, nil] Default text to show when no entries are selected.
|
|
92
117
|
# @param min_values [Integer, nil] The minimum amount of values a user must select.
|
|
93
118
|
# @param max_values [Integer, nil] The maximum amount of values a user can select.
|
|
94
119
|
# @param disabled [true, false, nil] Grey out the component to make it unusable.
|
|
95
|
-
def role_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
|
|
96
|
-
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :role_select).to_h
|
|
120
|
+
def role_select(custom_id:, id: nil, placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
|
|
121
|
+
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :role_select, id: id).to_h
|
|
97
122
|
end
|
|
98
123
|
|
|
99
124
|
# Add a select mentionable to this action row.
|
|
100
125
|
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
101
126
|
# There is a limit of 100 characters to each custom_id.
|
|
127
|
+
# @param id [Integer, nil] The unique 32-bit ID of the mentionable select. This is not to be confused with the `custom_id`.
|
|
102
128
|
# @param placeholder [String, nil] Default text to show when no entries are selected.
|
|
103
129
|
# @param min_values [Integer, nil] The minimum amount of values a user must select.
|
|
104
130
|
# @param max_values [Integer, nil] The maximum amount of values a user can select.
|
|
105
131
|
# @param disabled [true, false, nil] Grey out the component to make it unusable.
|
|
106
|
-
def mentionable_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
|
|
107
|
-
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :mentionable_select).to_h
|
|
132
|
+
def mentionable_select(custom_id:, id: nil, placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
|
|
133
|
+
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :mentionable_select, id: id).to_h
|
|
108
134
|
end
|
|
109
135
|
|
|
110
136
|
# Add a select channel to this action row.
|
|
111
137
|
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
112
138
|
# There is a limit of 100 characters to each custom_id.
|
|
139
|
+
# @param id [Integer, nil] The unique 32-bit ID of the channel select. This is not to be confused with the `custom_id`.
|
|
113
140
|
# @param placeholder [String, nil] Default text to show when no entries are selected.
|
|
114
141
|
# @param min_values [Integer, nil] The minimum amount of values a user must select.
|
|
115
142
|
# @param max_values [Integer, nil] The maximum amount of values a user can select.
|
|
116
143
|
# @param disabled [true, false, nil] Grey out the component to make it unusable.
|
|
117
|
-
|
|
118
|
-
|
|
144
|
+
# @param types [Array<Symbol, Integer>, nil] The channel types to include in the select menu.
|
|
145
|
+
def channel_select(custom_id:, id: nil, placeholder: nil, min_values: nil, max_values: nil, disabled: nil, types: nil)
|
|
146
|
+
builder = SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :channel_select, id: id).to_h
|
|
147
|
+
|
|
148
|
+
builder[:channel_types] = types.map { |type| Discordrb::Channel::TYPES[type] || type } if types
|
|
149
|
+
|
|
150
|
+
@components << builder
|
|
119
151
|
end
|
|
120
152
|
|
|
121
153
|
# @!visibility private
|
|
122
154
|
def to_h
|
|
123
|
-
{ type: COMPONENT_TYPES[:action_row], components: @components }
|
|
155
|
+
{ type: COMPONENT_TYPES[:action_row], id: @id, components: @components }.compact
|
|
124
156
|
end
|
|
125
157
|
end
|
|
126
158
|
|
|
127
159
|
# A builder to assist in adding options to select menus.
|
|
128
160
|
class SelectMenuBuilder
|
|
129
161
|
# @!visibility hidden
|
|
130
|
-
def initialize(custom_id, options = [], placeholder = nil, min_values = nil, max_values = nil, disabled = nil, select_type: :string_select)
|
|
162
|
+
def initialize(custom_id, options = [], placeholder = nil, min_values = nil, max_values = nil, disabled = nil, select_type: :string_select, id: nil, required: nil)
|
|
163
|
+
@id = id
|
|
131
164
|
@custom_id = custom_id
|
|
132
165
|
@options = options
|
|
133
166
|
@placeholder = placeholder
|
|
@@ -135,13 +168,14 @@ class Discordrb::Webhooks::View
|
|
|
135
168
|
@max_values = max_values
|
|
136
169
|
@disabled = disabled
|
|
137
170
|
@select_type = select_type
|
|
171
|
+
@required = required
|
|
138
172
|
end
|
|
139
173
|
|
|
140
174
|
# Add an option to this select menu.
|
|
141
175
|
# @param label [String] The title of this option.
|
|
142
176
|
# @param value [String] The value that this option represents.
|
|
143
177
|
# @param description [String, nil] An optional description of the option.
|
|
144
|
-
# @param emoji [#to_h, String, Integer] An emoji ID, or unicode emoji to attach to the button. Can also be
|
|
178
|
+
# @param emoji [#to_h, String, Integer] An emoji ID, or unicode emoji to attach to the button. Can also be an object
|
|
145
179
|
# that responds to `#to_h` which returns a hash in the format of `{ id: Integer, name: string }`.
|
|
146
180
|
# @param default [true, false, nil] Whether this is the default selected option.
|
|
147
181
|
def option(label:, value:, description: nil, emoji: nil, default: nil)
|
|
@@ -159,36 +193,282 @@ class Discordrb::Webhooks::View
|
|
|
159
193
|
def to_h
|
|
160
194
|
{
|
|
161
195
|
type: COMPONENT_TYPES[@select_type],
|
|
196
|
+
id: @id,
|
|
162
197
|
options: @options,
|
|
163
198
|
placeholder: @placeholder,
|
|
164
199
|
min_values: @min_values,
|
|
165
200
|
max_values: @max_values,
|
|
166
201
|
custom_id: @custom_id,
|
|
167
|
-
disabled: @disabled
|
|
168
|
-
|
|
202
|
+
disabled: @disabled,
|
|
203
|
+
required: @required
|
|
204
|
+
}.compact
|
|
169
205
|
end
|
|
170
206
|
end
|
|
171
207
|
|
|
172
|
-
|
|
208
|
+
# A text display component allows you to send message content.
|
|
209
|
+
class TextDisplayBuilder
|
|
210
|
+
# Create a text display component.
|
|
211
|
+
# @param content [String] The content of the text display component.
|
|
212
|
+
# @param id [Integer, nil] The unique 32-bit ID of the text display component.
|
|
213
|
+
def initialize(content:, id: nil)
|
|
214
|
+
@id = id
|
|
215
|
+
@content = content
|
|
216
|
+
end
|
|
173
217
|
|
|
174
|
-
|
|
175
|
-
|
|
218
|
+
# @!visibility private
|
|
219
|
+
def to_h
|
|
220
|
+
{ type: COMPONENT_TYPES[:text_display], id: @id, content: @content }.compact
|
|
221
|
+
end
|
|
222
|
+
end
|
|
176
223
|
|
|
177
|
-
|
|
224
|
+
# A separator allows you to add a barrier between components.
|
|
225
|
+
class SeparatorBuilder
|
|
226
|
+
# Create a separator component.
|
|
227
|
+
# @param divider [true, false] Whether or not the separator should act as a visible barrier.
|
|
228
|
+
# @param id [Integer, nil] The unique 32-bit ID of the separator component.
|
|
229
|
+
# @param spacing [Symbol, Integer] The size of the separator component's padding. See {SEPARATOR_SIZES}.
|
|
230
|
+
def initialize(divider:, id: nil, spacing: nil)
|
|
231
|
+
@id = id
|
|
232
|
+
@divider = divider
|
|
233
|
+
@spacing = SEPARATOR_SIZES[spacing] || spacing
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# @!visibility private
|
|
237
|
+
def to_h
|
|
238
|
+
{ type: COMPONENT_TYPES[:separator], id: @id, divider: @divider, spacing: @spacing }.compact
|
|
239
|
+
end
|
|
178
240
|
end
|
|
179
241
|
|
|
180
|
-
#
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
242
|
+
# A file component lets you send a file via an attachment://<filename> reference.
|
|
243
|
+
class FileBuilder
|
|
244
|
+
# Create a file component.
|
|
245
|
+
# @param url [String] An `attachment://<filename>` reference to the attached file.
|
|
246
|
+
# @param id [Integer, nil] The unique 32-bit ID of the file component.
|
|
247
|
+
# @param spoiler [true, false] Whether or not to apply a spoiler label to the file.
|
|
248
|
+
def initialize(url:, id: nil, spoiler: false)
|
|
249
|
+
@id = id
|
|
250
|
+
@file = { url: }
|
|
251
|
+
@spoiler = spoiler
|
|
252
|
+
end
|
|
184
253
|
|
|
185
|
-
|
|
254
|
+
# @!visibility private
|
|
255
|
+
def to_h
|
|
256
|
+
{ type: COMPONENT_TYPES[:file], id: @id, spoiler: @spoiler, file: @file }.compact
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
# A media gallery component is a gallery grid.
|
|
261
|
+
class MediaGalleryBuilder
|
|
262
|
+
# Create a media gallery component.
|
|
263
|
+
# @param id [Integer, nil] The unique 32-bit ID of the media gallery component.
|
|
264
|
+
# @yieldparam builder [MediaGalleryBuilder] Yields the initialized media gallery component.
|
|
265
|
+
def initialize(id: nil)
|
|
266
|
+
@id = id
|
|
267
|
+
@items = []
|
|
268
|
+
|
|
269
|
+
yield self if block_given?
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# Add a gallery item to the media gallery component.
|
|
273
|
+
# @param url [String] The URL to the gallery item's media.
|
|
274
|
+
# @param description [String, nil] The description of the gallery item.
|
|
275
|
+
# @param spoiler [true, false] Whether or not to apply a spoiler label to the gallery item.
|
|
276
|
+
def item(url:, description: nil, spoiler: false)
|
|
277
|
+
@items << { media: { url: }, description: description, spoiler: spoiler }.compact
|
|
278
|
+
end
|
|
186
279
|
|
|
187
|
-
|
|
280
|
+
# @!visibility private
|
|
281
|
+
def to_h
|
|
282
|
+
{ type: COMPONENT_TYPES[:media_gallery], id: @id, items: @items }.compact
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
# A section allows you to group together an accessory with text display components.
|
|
287
|
+
class SectionBuilder
|
|
288
|
+
# Create a section component.
|
|
289
|
+
# @param id [Integer, nil] The unique 32-bit ID of the section component.
|
|
290
|
+
# @yieldparam builder [SectionBuilder] Yields the initialized section component.
|
|
291
|
+
def initialize(id: nil)
|
|
292
|
+
@id = id
|
|
293
|
+
@accessory = nil
|
|
294
|
+
@components = []
|
|
295
|
+
|
|
296
|
+
yield self if block_given?
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
# Add a text display component to this section.
|
|
300
|
+
# @see TextDisplayBuilder#initialize
|
|
301
|
+
def text_display(...)
|
|
302
|
+
@components << TextDisplayBuilder.new(...)
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
# Set the thumbnail for the section. This is mutually exclusive with {#button}.
|
|
306
|
+
# @param url [String] The URL to the thumbnail image.
|
|
307
|
+
# @param id [Integer, nil] The unique 32-bit ID of the thumbnail component.
|
|
308
|
+
# @param description [String, nil] The description of the thumbnail.
|
|
309
|
+
# @param spoiler [true, false] Whether or not to apply a spoiler label to the thumbnail.
|
|
310
|
+
def thumbnail(url:, id: nil, description: nil, spoiler: false)
|
|
311
|
+
@accessory = { type: COMPONENT_TYPES[:thumbnail], id: id, media: { url: }, description: description, spoiler: spoiler }.compact
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
# Set the button for the section. This is mutually exclusive with {#thumbnail}.
|
|
315
|
+
# @param style [Symbol, Integer] The button's style type. See {BUTTON_STYLES}
|
|
316
|
+
# @param id [Integer, nil] The unique 32-bit ID of the button component. This is not to be confused with the `custom_id`.
|
|
317
|
+
# @param label [String, nil] The text label for the button. Either a label or emoji must be provided.
|
|
318
|
+
# @param emoji [#to_h, String, Integer] An emoji ID, or unicode emoji to attach to the button. Can also be an object
|
|
319
|
+
# that responds to `#to_h` which returns a hash in the format of `{ id: Integer, name: string }`.
|
|
320
|
+
# @param custom_id [String] Custom IDs are used to pass state to the events that are raised from interactions.
|
|
321
|
+
# There is a limit of 100 characters to each custom_id.
|
|
322
|
+
# @param disabled [true, false] Whether this button is disabled and shown as greyed out.
|
|
323
|
+
# @param url [String, nil] The URL, when using a link style button.
|
|
324
|
+
def button(style:, id: nil, label: nil, emoji: nil, custom_id: nil, disabled: nil, url: nil)
|
|
325
|
+
style = BUTTON_STYLES[style] || style
|
|
326
|
+
|
|
327
|
+
emoji = case emoji
|
|
328
|
+
when Integer, String
|
|
329
|
+
emoji.to_i.positive? ? { id: emoji } : { name: emoji }
|
|
330
|
+
else
|
|
331
|
+
emoji&.to_h
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
@accessory = { type: COMPONENT_TYPES[:button], id: id, label: label, emoji: emoji, style: style, custom_id: custom_id, disabled: disabled, url: url }.compact
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
# @!visibility private
|
|
338
|
+
def to_h
|
|
339
|
+
{ type: COMPONENT_TYPES[:section], id: @id, components: @components.map(&:to_h), accessory: @accessory }.compact
|
|
340
|
+
end
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
# This builder can be used to construct a container. These are similar to embeds.
|
|
344
|
+
class ContainerBuilder
|
|
345
|
+
# Create a container component.
|
|
346
|
+
# @param id [Integer, nil] The unique 32-bit ID of the container component.
|
|
347
|
+
# @param colour [Array, Integer, String, ColourRGB, nil] The accent colour of the container
|
|
348
|
+
# component. This argument can be passed via the American spelling (`color:`) as well.
|
|
349
|
+
# @param spoiler [true, false] Whether or not to apply a spoiler label to the container component.
|
|
350
|
+
# @yieldparam builder [ContainerBuilder] Yields the initialized container component.
|
|
351
|
+
def initialize(id: nil, color: nil, colour: nil, spoiler: false)
|
|
352
|
+
@id = id
|
|
353
|
+
@spoiler = spoiler
|
|
354
|
+
@components = []
|
|
355
|
+
self.colour = (colour || color)
|
|
356
|
+
|
|
357
|
+
yield self if block_given?
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Add a row component to the container.
|
|
361
|
+
# @see RowBuilder#initialize
|
|
362
|
+
def row(...)
|
|
363
|
+
@components << RowBuilder.new(...)
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
# Add a file component to the container.
|
|
367
|
+
# @see FileBuilder#initialize
|
|
368
|
+
def file(...)
|
|
369
|
+
@components << FileBuilder.new(...)
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
alias_method :file_display, :file
|
|
373
|
+
|
|
374
|
+
# Add a section component to the container.
|
|
375
|
+
# @see SectionBuilder#initialize
|
|
376
|
+
def section(...)
|
|
377
|
+
@components << SectionBuilder.new(...)
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
# Add a separator component to the container.
|
|
381
|
+
# @see SeparatorBuilder#initialize
|
|
382
|
+
def separator(...)
|
|
383
|
+
@components << SeparatorBuilder.new(...)
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
# Add a text display component to the container.
|
|
387
|
+
# @see TextDisplayBuilder#initialize
|
|
388
|
+
def text_display(...)
|
|
389
|
+
@components << TextDisplayBuilder.new(...)
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
# Add a media gallery component to the container.
|
|
393
|
+
# @see MediaGalleryBuilder#initialize
|
|
394
|
+
def media_gallery(...)
|
|
395
|
+
@components << MediaGalleryBuilder.new(...)
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
# Set the color of the container.
|
|
399
|
+
# @param colour [Array, Integer, String, ColourRGB, nil] The accent colour of the container component, or `nil` to clear the accent colour.
|
|
400
|
+
def colour=(colour)
|
|
401
|
+
@colour = case colour
|
|
402
|
+
when Array
|
|
403
|
+
(colour[0] << 16) | (colour[1] << 8) | colour[2]
|
|
404
|
+
when String
|
|
405
|
+
colour.delete('#').to_i(16)
|
|
406
|
+
else
|
|
407
|
+
colour&.to_i
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
alias_method :color=, :colour=
|
|
412
|
+
|
|
413
|
+
# @!visibility private
|
|
414
|
+
def to_h
|
|
415
|
+
{ type: COMPONENT_TYPES[:container], id: @id, accent_color: @colour, spoiler: @spoiler, components: @components.map(&:to_h) }.compact
|
|
416
|
+
end
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
# @!visibility private
|
|
420
|
+
def initialize
|
|
421
|
+
@components = []
|
|
422
|
+
|
|
423
|
+
yield self if block_given?
|
|
188
424
|
end
|
|
189
425
|
|
|
190
426
|
# @!visibility private
|
|
191
427
|
def to_a
|
|
192
|
-
@
|
|
428
|
+
@components.map(&:to_h)
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
# Add a row component to the view.
|
|
432
|
+
# @see RowBuilder#initialize
|
|
433
|
+
def row(...)
|
|
434
|
+
@components << RowBuilder.new(...)
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
# Add a file component to the view.
|
|
438
|
+
# @see FileBuilder#initialize
|
|
439
|
+
def file(...)
|
|
440
|
+
@components << FileBuilder.new(...)
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
alias_method :file_display, :file
|
|
444
|
+
|
|
445
|
+
# Add a section component to the view.
|
|
446
|
+
# @see SectionBuilder#initialize
|
|
447
|
+
def section(...)
|
|
448
|
+
@components << SectionBuilder.new(...)
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
# Add a separator component to the view.
|
|
452
|
+
# @see SeparatorBuilder#initialize
|
|
453
|
+
def separator(...)
|
|
454
|
+
@components << SeparatorBuilder.new(...)
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
# Add a container component to the view.
|
|
458
|
+
# @see ContainerBuilder#initialize
|
|
459
|
+
def container(...)
|
|
460
|
+
@components << ContainerBuilder.new(...)
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
# Add a text display component to the view.
|
|
464
|
+
# @see TextDisplayBuilder#initialize
|
|
465
|
+
def text_display(...)
|
|
466
|
+
@components << TextDisplayBuilder.new(...)
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
# Add a media gallery component to the view.
|
|
470
|
+
# @see MediaGalleryBuilder#initialize
|
|
471
|
+
def media_gallery(...)
|
|
472
|
+
@components << MediaGalleryBuilder.new(...)
|
|
193
473
|
end
|
|
194
474
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: discordrb-webhooks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- meew0
|
|
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
57
57
|
- !ruby/object:Gem::Version
|
|
58
58
|
version: '0'
|
|
59
59
|
requirements: []
|
|
60
|
-
rubygems_version:
|
|
60
|
+
rubygems_version: 4.0.10
|
|
61
61
|
specification_version: 4
|
|
62
62
|
summary: Webhook client for discordrb
|
|
63
63
|
test_files: []
|