Skip to content

Commit

Permalink
Bugfix - Kwarg forgotten in string_select method (#214)
Browse files Browse the repository at this point in the history
* Bugfix - Kwarg forgotten in string_select

  (probably forgotten during the last rebases)
  + Adding disabled attributes that were not put on the new components during the last rebases

  Fix PR #213

* select_type should not be an argument of the string_select method after all

  The value should be set in the same way as the methods that follow it
  + Modification of the select_menus example to add the disabled attribute
  • Loading branch information
Dakurei authored Apr 22, 2023
1 parent 2011ac6 commit 3699bc0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
9 changes: 9 additions & 0 deletions examples/select_menus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
end
)

event.channel.send_message(
'user_select', false, nil, nil, nil, nil,
Discordrb::Components::View.new do |builder|
builder.row do |r|
r.user_select(custom_id: 'user_select', placeholder: 'Test of UserSelect', max_values: 3, disabled: true)
end
end
)

event.channel.send_message(
'user_select', false, nil, nil, nil, nil,
Discordrb::Components::View.new do |builder|
Expand Down
25 changes: 15 additions & 10 deletions lib/discordrb/webhooks/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ def button(style:, label: nil, emoji: nil, custom_id: nil, disabled: nil, url: n
# @param placeholder [String, nil] Default text to show when no entries are selected.
# @param min_values [Integer, nil] The minimum amount of values a user must select.
# @param max_values [Integer, nil] The maximum amount of values a user can select.
# @param disabled [true, false, nil] Grey out the component to make it unusable.
# @yieldparam builder [SelectMenuBuilder]
def string_select(custom_id:, options: [], placeholder: nil, min_values: nil, max_values: nil, disabled: nil, select_type: :string_select)
builder = SelectMenuBuilder.new(custom_id, options, placeholder, min_values, max_values, disabled, select_type)
def string_select(custom_id:, options: [], placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
builder = SelectMenuBuilder.new(custom_id, options, placeholder, min_values, max_values, disabled, select_type: :string_select)

yield builder if block_given?

Expand All @@ -79,8 +80,9 @@ def string_select(custom_id:, options: [], placeholder: nil, min_values: nil, ma
# @param placeholder [String, nil] Default text to show when no entries are selected.
# @param min_values [Integer, nil] The minimum amount of values a user must select.
# @param max_values [Integer, nil] The maximum amount of values a user can select.
def user_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil)
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, select_type: :user_select).to_h
# @param disabled [true, false, nil] Grey out the component to make it unusable.
def user_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :user_select).to_h
end

# Add a select role to this action row.
Expand All @@ -89,8 +91,9 @@ def user_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil)
# @param placeholder [String, nil] Default text to show when no entries are selected.
# @param min_values [Integer, nil] The minimum amount of values a user must select.
# @param max_values [Integer, nil] The maximum amount of values a user can select.
def role_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil)
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, select_type: :role_select).to_h
# @param disabled [true, false, nil] Grey out the component to make it unusable.
def role_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :role_select).to_h
end

# Add a select mentionable to this action row.
Expand All @@ -99,8 +102,9 @@ def role_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil)
# @param placeholder [String, nil] Default text to show when no entries are selected.
# @param min_values [Integer, nil] The minimum amount of values a user must select.
# @param max_values [Integer, nil] The maximum amount of values a user can select.
def mentionable_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil)
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, select_type: :mentionable_select).to_h
# @param disabled [true, false, nil] Grey out the component to make it unusable.
def mentionable_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :mentionable_select).to_h
end

# Add a select channel to this action row.
Expand All @@ -109,8 +113,9 @@ def mentionable_select(custom_id:, placeholder: nil, min_values: nil, max_values
# @param placeholder [String, nil] Default text to show when no entries are selected.
# @param min_values [Integer, nil] The minimum amount of values a user must select.
# @param max_values [Integer, nil] The maximum amount of values a user can select.
def channel_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil)
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, select_type: :channel_select).to_h
# @param disabled [true, false, nil] Grey out the component to make it unusable.
def channel_select(custom_id:, placeholder: nil, min_values: nil, max_values: nil, disabled: nil)
@components << SelectMenuBuilder.new(custom_id, [], placeholder, min_values, max_values, disabled, select_type: :channel_select).to_h
end

# @!visibility private
Expand Down

0 comments on commit 3699bc0

Please sign in to comment.