Method: Discorb::Button#to_hash

Defined in:
lib/discorb/components/button.rb

#to_hashHash

Converts the button to a hash.

Returns:

  • (Hash)

    A hash representation of the button.

See Also:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/discorb/components/button.rb', line 61

def to_hash
  if @style == :link
    {
      type: 2,
      label: @label,
      style: STYLES[@style],
      url: @url,
      emoji: @emoji&.to_hash,
      disabled: @disabled
    }
  else
    {
      type: 2,
      label: @label,
      style: STYLES[@style],
      custom_id: @custom_id,
      emoji: @emoji&.to_hash,
      disabled: @disabled
    }
  end
end