onyxcord 3.2.3 → 3.2.5
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/onyxcord/core/version.rb +1 -1
- data/lib/onyxcord/models/component.rb +13 -0
- data/lib/onyxcord/webhooks/modal.rb +44 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58b6c40e04d80caf8907786964a17a7499074e7f2a213ba0c8d95aa4a7a97617
|
|
4
|
+
data.tar.gz: f5a62bd27e38a81f849b0cdd8e4f3210e73f684775320929a7f01cd963d3b9fc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5fd3b0d1966b6e37b23675bc5ac1948b059cfe9b4777032b5d573c2bb199cf540776291b51c1e92a5e368021e5191d09089cccb18fd6f04e2438c193914b8ac
|
|
7
|
+
data.tar.gz: 3ad8f80253da0da08e946870590bbf10b9ffd70da02fe24f838d67d0bce5d93f58302f03493b7e187fe00a76a36c53d63e4c6cec67e698bbbabba43cd4779a0a
|
|
@@ -49,6 +49,12 @@ module OnyxCord
|
|
|
49
49
|
class ActionRow
|
|
50
50
|
include Enumerable
|
|
51
51
|
|
|
52
|
+
DELEGATED_COMPONENT_METHODS = %i[
|
|
53
|
+
custom_id
|
|
54
|
+
value
|
|
55
|
+
values
|
|
56
|
+
].freeze
|
|
57
|
+
|
|
52
58
|
# @return [Integer] the numeric identifier of the action row.
|
|
53
59
|
attr_reader :id
|
|
54
60
|
|
|
@@ -84,6 +90,13 @@ module OnyxCord
|
|
|
84
90
|
def to_a
|
|
85
91
|
@components
|
|
86
92
|
end
|
|
93
|
+
|
|
94
|
+
DELEGATED_COMPONENT_METHODS.each do |name|
|
|
95
|
+
define_method(name) do
|
|
96
|
+
component = @components.first
|
|
97
|
+
component.public_send(name) if @components.one? && component.respond_to?(name)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
87
100
|
end
|
|
88
101
|
|
|
89
102
|
# An interactable button component.
|
|
@@ -39,9 +39,53 @@ class OnyxCord::Webhooks::Modal
|
|
|
39
39
|
@components << LabelBuilder.new(...)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
# Add a legacy action row to the modal.
|
|
43
|
+
def row(id: nil)
|
|
44
|
+
@components << LegacyRowBuilder.new(id: id) { |row| yield row }
|
|
45
|
+
end
|
|
46
|
+
|
|
42
47
|
# Add a text display component to the view.
|
|
43
48
|
# @see Webhooks::View::TextDisplayBuilder#initialize
|
|
44
49
|
def text_display(...)
|
|
45
50
|
@components << OnyxCord::Webhooks::View::TextDisplayBuilder.new(...)
|
|
46
51
|
end
|
|
52
|
+
|
|
53
|
+
class LegacyRowBuilder
|
|
54
|
+
def initialize(id: nil)
|
|
55
|
+
@id = id
|
|
56
|
+
@components = []
|
|
57
|
+
|
|
58
|
+
yield self if block_given?
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def text_input(style:, custom_id:, id: nil, min_length: nil, max_length: nil, required: nil, value: nil, placeholder: nil, label: nil)
|
|
62
|
+
@components << {
|
|
63
|
+
type: COMPONENT_TYPES[:text_input],
|
|
64
|
+
custom_id: custom_id,
|
|
65
|
+
id: id,
|
|
66
|
+
label: label,
|
|
67
|
+
style: LabelBuilder::TEXT_INPUT_STYLES[style] || style,
|
|
68
|
+
min_length: min_length,
|
|
69
|
+
max_length: max_length,
|
|
70
|
+
required: required,
|
|
71
|
+
value: value,
|
|
72
|
+
placeholder: placeholder
|
|
73
|
+
}.compact
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def file_upload(custom_id:, id: nil, min_values: nil, max_values: nil, required: nil)
|
|
77
|
+
@components << {
|
|
78
|
+
type: COMPONENT_TYPES[:file_upload],
|
|
79
|
+
custom_id: custom_id,
|
|
80
|
+
id: id,
|
|
81
|
+
min_values: min_values,
|
|
82
|
+
max_values: max_values,
|
|
83
|
+
required: required
|
|
84
|
+
}.compact
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def to_h
|
|
88
|
+
{ type: COMPONENT_TYPES[:action_row], id: @id, components: @components }.compact
|
|
89
|
+
end
|
|
90
|
+
end
|
|
47
91
|
end
|