Class: Rubycord::Components::Button
- Inherits:
-
Object
- Object
- Rubycord::Components::Button
- Defined in:
- lib/rubycord/data/component.rb
Overview
An interactable button component.
Instance Attribute Summary collapse
- #custom_id ⇒ String readonly
- #disabled ⇒ true, false readonly
- #emoji ⇒ Emoji? readonly
- #label ⇒ String readonly
- #style ⇒ Integer readonly
- #url ⇒ String? readonly
Instance Method Summary collapse
-
#await_click(key, **attributes) ⇒ Object
Await a button click.
-
#await_click!(**attributes) ⇒ Object
Await a button click, blocking.
- #danger? ⇒ true, false
- #link? ⇒ true, false
- #primary? ⇒ true, false
- #secondary? ⇒ true, false
- #success? ⇒ true, false
Instance Attribute Details
#custom_id ⇒ String (readonly)
67 68 69 |
# File 'lib/rubycord/data/component.rb', line 67 def custom_id @custom_id end |
#disabled ⇒ true, false (readonly)
70 71 72 |
# File 'lib/rubycord/data/component.rb', line 70 def disabled @disabled end |
#emoji ⇒ Emoji? (readonly)
76 77 78 |
# File 'lib/rubycord/data/component.rb', line 76 def emoji @emoji end |
#label ⇒ String (readonly)
61 62 63 |
# File 'lib/rubycord/data/component.rb', line 61 def label @label end |
#style ⇒ Integer (readonly)
64 65 66 |
# File 'lib/rubycord/data/component.rb', line 64 def style @style end |
#url ⇒ String? (readonly)
73 74 75 |
# File 'lib/rubycord/data/component.rb', line 73 def url @url end |
Instance Method Details
#await_click(key, **attributes) ⇒ Object
Await a button click
107 108 109 |
# File 'lib/rubycord/data/component.rb', line 107 def await_click(key, **attributes, &) @bot.add_await(key, Rubycord::Events::ButtonEvent, {custom_id: @custom_id}.merge(attributes), &) end |
#await_click!(**attributes) ⇒ Object
Await a button click, blocking.
112 113 114 |
# File 'lib/rubycord/data/component.rb', line 112 def await_click!(**attributes, &) @bot.add_await!(Rubycord::Events::ButtonEvent, {custom_id: @custom_id}.merge(attributes), &) end |
#danger? ⇒ true, false
100 101 102 103 104 |
# File 'lib/rubycord/data/component.rb', line 100 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method(:"#{name}?") do @style == value end end |
#link? ⇒ true, false
100 101 102 103 104 |
# File 'lib/rubycord/data/component.rb', line 100 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method(:"#{name}?") do @style == value end end |
#primary? ⇒ true, false
100 101 102 103 104 |
# File 'lib/rubycord/data/component.rb', line 100 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method(:"#{name}?") do @style == value end end |
#secondary? ⇒ true, false
100 101 102 103 104 |
# File 'lib/rubycord/data/component.rb', line 100 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method(:"#{name}?") do @style == value end end |
#success? ⇒ true, false
100 101 102 103 104 |
# File 'lib/rubycord/data/component.rb', line 100 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method(:"#{name}?") do @style == value end end |