Class: Discordrb::Webhooks::EmbedAuthor

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/webhooks/embeds.rb

Overview

An embed's author will be shown at the top to indicate who "authored" the particular event the webhook was sent for.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, url: nil, icon_url: nil) ⇒ EmbedAuthor

Creates a new author object.

Parameters:

  • name (String, nil) (defaults to: nil)

    The name of the author.

  • url (String, nil) (defaults to: nil)

    The URL the name should link to.

  • icon_url (String, nil) (defaults to: nil)

    The URL of the icon to be displayed next to the author.


196
197
198
199
200
# File 'lib/discordrb/webhooks/embeds.rb', line 196

def initialize(name: nil, url: nil, icon_url: nil)
  @name = name
  @url = url
  @icon_url = icon_url
end

Instance Attribute Details

#icon_urlString?

Returns URL of the icon to be displayed next to the author.

Returns:

  • (String, nil)

    URL of the icon to be displayed next to the author


190
191
192
# File 'lib/discordrb/webhooks/embeds.rb', line 190

def icon_url
  @icon_url
end

#nameString?

Returns name of the author.

Returns:

  • (String, nil)

    name of the author


184
185
186
# File 'lib/discordrb/webhooks/embeds.rb', line 184

def name
  @name
end

#urlString?

Returns URL the name should link to.

Returns:

  • (String, nil)

    URL the name should link to


187
188
189
# File 'lib/discordrb/webhooks/embeds.rb', line 187

def url
  @url
end

Instance Method Details

#to_hashHash

Returns a hash representation of this embed author, to be converted to JSON.

Returns:

  • (Hash)

    a hash representation of this embed author, to be converted to JSON.


203
204
205
206
207
208
209
# File 'lib/discordrb/webhooks/embeds.rb', line 203

def to_hash
  {
    name: @name,
    url: @url,
    icon_url: @icon_url
  }
end