Class: OnyxCord::Components::Button
- Inherits:
-
Object
- Object
- OnyxCord::Components::Button
- Defined in:
- lib/onyxcord/models/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.
-
#sku_id ⇒ Integer?
readonly
The SKU ID of the button if it is a premium 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.
-
#premium? ⇒ true, false
Whether the button starts a premium SKU purchase.
-
#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/onyxcord/models/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/onyxcord/models/component.rb', line 104 def disabled @disabled end |
#emoji ⇒ Emoji? (readonly)
Returns the custom emoji of the button component.
113 114 115 |
# File 'lib/onyxcord/models/component.rb', line 113 def emoji @emoji end |
#id ⇒ Integer (readonly)
Returns the numeric identifier of the button.
92 93 94 |
# File 'lib/onyxcord/models/component.rb', line 92 def id @id end |
#label ⇒ String (readonly)
Returns the label of the button.
95 96 97 |
# File 'lib/onyxcord/models/component.rb', line 95 def label @label end |
#sku_id ⇒ Integer? (readonly)
Returns the SKU ID of the button if it is a premium button.
110 111 112 |
# File 'lib/onyxcord/models/component.rb', line 110 def sku_id @sku_id end |
#style ⇒ Integer (readonly)
Returns the style of the button.
98 99 100 |
# File 'lib/onyxcord/models/component.rb', line 98 def style @style end |
#url ⇒ String? (readonly)
Returns the URL of the button if applicable.
107 108 109 |
# File 'lib/onyxcord/models/component.rb', line 107 def url @url end |
Instance Method Details
#await_click(key, **attributes, &block) ⇒ Object
Await a button click.
147 148 149 |
# File 'lib/onyxcord/models/component.rb', line 147 def await_click(key, **attributes, &block) @bot.add_await(key, OnyxCord::Events::ButtonEvent, { custom_id: @custom_id }.merge!(attributes), &block) end |
#await_click!(**attributes, &block) ⇒ Object
Await a button click, blocking.
152 153 154 |
# File 'lib/onyxcord/models/component.rb', line 152 def await_click!(**attributes, &block) @bot.add_await!(OnyxCord::Events::ButtonEvent, { custom_id: @custom_id }.merge!(attributes), &block) end |
#danger? ⇒ true, false
Returns whether the button denotes a dangerous action in the group.
140 141 142 143 144 |
# File 'lib/onyxcord/models/component.rb', line 140 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.
140 141 142 143 144 |
# File 'lib/onyxcord/models/component.rb', line 140 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |
#premium? ⇒ true, false
Returns whether the button starts a premium SKU purchase.
140 141 142 143 144 |
# File 'lib/onyxcord/models/component.rb', line 140 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.
140 141 142 143 144 |
# File 'lib/onyxcord/models/component.rb', line 140 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.
140 141 142 143 144 |
# File 'lib/onyxcord/models/component.rb', line 140 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.
140 141 142 143 144 |
# File 'lib/onyxcord/models/component.rb', line 140 Webhooks::View::BUTTON_STYLES.each do |name, value| define_method("#{name}?") do @style == value end end |