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
- #disabled ⇒ true, false readonly
- #emoji ⇒ Emoji? readonly
- #label ⇒ String readonly
- #style ⇒ Integer readonly
- #url ⇒ String? readonly
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
- #link? ⇒ true, false
- #primary? ⇒ true, false
- #secondary? ⇒ true, false
- #success? ⇒ true, false
Instance Attribute Details
#custom_id ⇒ String (readonly)
69 70 71 |
# File 'lib/discordrb/data/component.rb', line 69 def custom_id @custom_id end |
#disabled ⇒ true, false (readonly)
72 73 74 |
# File 'lib/discordrb/data/component.rb', line 72 def disabled @disabled end |
#emoji ⇒ Emoji? (readonly)
78 79 80 |
# File 'lib/discordrb/data/component.rb', line 78 def emoji @emoji end |
#label ⇒ String (readonly)
63 64 65 |
# File 'lib/discordrb/data/component.rb', line 63 def label @label end |
#style ⇒ Integer (readonly)
66 67 68 |
# File 'lib/discordrb/data/component.rb', line 66 def style @style end |
#url ⇒ String? (readonly)
75 76 77 |
# File 'lib/discordrb/data/component.rb', line 75 def url @url end |
Instance Method Details
#await_click(key, **attributes, &block) ⇒ Object
Await a button click
109 110 111 |
# File 'lib/discordrb/data/component.rb', line 109 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.
114 115 116 |
# File 'lib/discordrb/data/component.rb', line 114 def await_click!(**attributes, &block) @bot.add_await!(Discordrb::Events::ButtonEvent, { custom_id: @custom_id }.merge(attributes), &block) end |
#danger? ⇒ true, false
102 103 104 105 106 |
# File 'lib/discordrb/data/component.rb', line 102 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#link? ⇒ true, false
102 103 104 105 106 |
# File 'lib/discordrb/data/component.rb', line 102 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#primary? ⇒ true, false
102 103 104 105 106 |
# File 'lib/discordrb/data/component.rb', line 102 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#secondary? ⇒ true, false
102 103 104 105 106 |
# File 'lib/discordrb/data/component.rb', line 102 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#success? ⇒ true, false
102 103 104 105 106 |
# File 'lib/discordrb/data/component.rb', line 102 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |