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)
61 62 63 |
# File 'lib/discordrb/data/component.rb', line 61 def custom_id @custom_id end |
#disabled ⇒ true, false (readonly)
64 65 66 |
# File 'lib/discordrb/data/component.rb', line 64 def disabled @disabled end |
#emoji ⇒ Emoji? (readonly)
70 71 72 |
# File 'lib/discordrb/data/component.rb', line 70 def emoji @emoji end |
#label ⇒ String (readonly)
55 56 57 |
# File 'lib/discordrb/data/component.rb', line 55 def label @label end |
#style ⇒ Integer (readonly)
58 59 60 |
# File 'lib/discordrb/data/component.rb', line 58 def style @style end |
#url ⇒ String? (readonly)
67 68 69 |
# File 'lib/discordrb/data/component.rb', line 67 def url @url end |
Instance Method Details
#await_click(key, **attributes, &block) ⇒ Object
Await a button click
101 102 103 |
# File 'lib/discordrb/data/component.rb', line 101 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.
106 107 108 |
# File 'lib/discordrb/data/component.rb', line 106 def await_click!(**attributes, &block) @bot.add_await!(Discordrb::Events::ButtonEvent, { custom_id: @custom_id }.merge(attributes), &block) end |
#danger? ⇒ true, false
94 95 96 97 98 |
# File 'lib/discordrb/data/component.rb', line 94 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#link? ⇒ true, false
94 95 96 97 98 |
# File 'lib/discordrb/data/component.rb', line 94 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#primary? ⇒ true, false
94 95 96 97 98 |
# File 'lib/discordrb/data/component.rb', line 94 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#secondary? ⇒ true, false
94 95 96 97 98 |
# File 'lib/discordrb/data/component.rb', line 94 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#success? ⇒ true, false
94 95 96 97 98 |
# File 'lib/discordrb/data/component.rb', line 94 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |