Class: Discordrb::Components::Button

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/data/component.rb

Overview

An interactable button component.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#custom_idString (readonly)

Returns:



61
62
63
# File 'lib/discordrb/data/component.rb', line 61

def custom_id
  @custom_id
end

#disabledtrue, false (readonly)

Returns:

  • (true, false)


64
65
66
# File 'lib/discordrb/data/component.rb', line 64

def disabled
  @disabled
end

#emojiEmoji? (readonly)

Returns:



70
71
72
# File 'lib/discordrb/data/component.rb', line 70

def emoji
  @emoji
end

#labelString (readonly)

Returns:



55
56
57
# File 'lib/discordrb/data/component.rb', line 55

def label
  @label
end

#styleInteger (readonly)

Returns:



58
59
60
# File 'lib/discordrb/data/component.rb', line 58

def style
  @style
end

#urlString? (readonly)

Returns:



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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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