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:



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

def custom_id
  @custom_id
end

#disabledtrue, false (readonly)

Returns:

  • (true, false)


72
73
74
# File 'lib/discordrb/data/component.rb', line 72

def disabled
  @disabled
end

#emojiEmoji? (readonly)

Returns:



78
79
80
# File 'lib/discordrb/data/component.rb', line 78

def emoji
  @emoji
end

#labelString (readonly)

Returns:



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

def label
  @label
end

#styleInteger (readonly)

Returns:



66
67
68
# File 'lib/discordrb/data/component.rb', line 66

def style
  @style
end

#urlString? (readonly)

Returns:



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

Returns:

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

Returns:

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

Returns:

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

Returns:

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

Returns:

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