Class: Discordrb::Components::Button
- Inherits:
-
Object
- Object
- Discordrb::Components::Button
- Defined in:
- lib/discordrb/data/component.rb
Overview
An interactable button component.
Instance Attribute Summary collapse
-
#custom_id ⇒ String
readonly
The custom ID of the button.
-
#disabled ⇒ true, false
readonly
Whether or not the button is disabled.
-
#emoji ⇒ Emoji?
readonly
The custom emoji of the button component.
-
#id ⇒ Integer
readonly
The numeric identifier of the button.
-
#label ⇒ String
readonly
The label of the button.
-
#style ⇒ Integer
readonly
The style of the button.
-
#url ⇒ String?
readonly
The URL of the button if applicable.
Instance Method Summary collapse
-
#await_click(key, **attributes, &block) ⇒ Object
Await a button click.
-
#await_click!(**attributes, &block) ⇒ Object
Await a button click, blocking.
-
#danger? ⇒ true, false
Whether the button denotes a dangerous action in the group.
-
#link? ⇒ true, false
Whether the button is a container for a URL that will open upon click.
-
#primary? ⇒ true, false
Whether the button is a primary option in the group.
-
#secondary? ⇒ true, false
Whether the button denotes a secondary option in the group.
-
#success? ⇒ true, false
Whether the button denotes a success action in the group.
Instance Attribute Details
#custom_id ⇒ String (readonly)
Returns the custom ID of the button.
101 102 103 |
# File 'lib/discordrb/data/component.rb', line 101 def custom_id @custom_id end |
#disabled ⇒ true, false (readonly)
Returns whether or not the button is disabled.
104 105 106 |
# File 'lib/discordrb/data/component.rb', line 104 def disabled @disabled end |
#emoji ⇒ Emoji? (readonly)
Returns the custom emoji of the button component.
110 111 112 |
# File 'lib/discordrb/data/component.rb', line 110 def emoji @emoji end |
#id ⇒ Integer (readonly)
Returns the numeric identifier of the button.
92 93 94 |
# File 'lib/discordrb/data/component.rb', line 92 def id @id end |
#label ⇒ String (readonly)
Returns the label of the button.
95 96 97 |
# File 'lib/discordrb/data/component.rb', line 95 def label @label end |
#style ⇒ Integer (readonly)
Returns the style of the button.
98 99 100 |
# File 'lib/discordrb/data/component.rb', line 98 def style @style end |
#url ⇒ String? (readonly)
Returns the URL of the button if applicable.
107 108 109 |
# File 'lib/discordrb/data/component.rb', line 107 def url @url end |
Instance Method Details
#await_click(key, **attributes, &block) ⇒ Object
Await a button click.
141 142 143 |
# File 'lib/discordrb/data/component.rb', line 141 def await_click(key, **attributes, &block) @bot.add_await(key, Discordrb::Events::ButtonEvent, { custom_id: @custom_id }.merge!(attributes), &block) end |
#await_click!(**attributes, &block) ⇒ Object
Await a button click, blocking.
146 147 148 |
# File 'lib/discordrb/data/component.rb', line 146 def await_click!(**attributes, &block) @bot.add_await!(Discordrb::Events::ButtonEvent, { custom_id: @custom_id }.merge!(attributes), &block) end |
#danger? ⇒ true, false
Returns whether the button denotes a dangerous action in the group.
134 135 136 137 138 |
# File 'lib/discordrb/data/component.rb', line 134 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#link? ⇒ true, false
Returns whether the button is a container for a URL that will open upon click.
134 135 136 137 138 |
# File 'lib/discordrb/data/component.rb', line 134 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#primary? ⇒ true, false
Returns whether the button is a primary option in the group.
134 135 136 137 138 |
# File 'lib/discordrb/data/component.rb', line 134 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#secondary? ⇒ true, false
Returns whether the button denotes a secondary option in the group.
134 135 136 137 138 |
# File 'lib/discordrb/data/component.rb', line 134 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#success? ⇒ true, false
Returns whether the button denotes a success action in the group.
134 135 136 137 138 |
# File 'lib/discordrb/data/component.rb', line 134 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |