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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23d795e8a2baf1f58d15267e7b1b32814719aec6d8922397821fb9399798028b
4
- data.tar.gz: 1a10c95ab6f32f4d61899d2c0563bcbcb3ad4acd790051edaa18ed68a827d02c
3
+ metadata.gz: 58b6c40e04d80caf8907786964a17a7499074e7f2a213ba0c8d95aa4a7a97617
4
+ data.tar.gz: f5a62bd27e38a81f849b0cdd8e4f3210e73f684775320929a7f01cd963d3b9fc
5
5
  SHA512:
6
- metadata.gz: 26109c5e32a6349fdc4ff92950b8d4010b1e8e6347338e96fd4c45ca22f35df7367177bbaa1fef6d35b6d3ca4fc066f17e5ca8909d8ec360f23690d34fd96388
7
- data.tar.gz: 7b97e9f9e33a938332d49139270f5e1d8fc21a27627544c81053ab5cc5b2c408249ea5c97d62ee5216ce65e79a02c8a1abe1d84f5f002dd8bb16714b93e9f7e3
6
+ metadata.gz: d5fd3b0d1966b6e37b23675bc5ac1948b059cfe9b4777032b5d573c2bb199cf540776291b51c1e92a5e368021e5191d09089cccb18fd6f04e2438c193914b8ac
7
+ data.tar.gz: 3ad8f80253da0da08e946870590bbf10b9ffd70da02fe24f838d67d0bce5d93f58302f03493b7e187fe00a76a36c53d63e4c6cec67e698bbbabba43cd4779a0a
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OnyxCord
4
- VERSION = '3.2.3'
4
+ VERSION = '3.2.5'
5
5
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onyxcord
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Silva