Method: Discordrb::Channel#send_embed

Defined in:
lib/discordrb/data/channel.rb

#send_embed(message = '', embed = nil, attachments = nil, tts = false, allowed_mentions = nil, message_reference = nil, components = nil) {|embed| ... } ⇒ Message

Convenience method to send a message with an embed.

Examples:

Send a message with an embed

channel.send_embed do |embed|
  embed.title = 'The Ruby logo'
  embed.image = Discordrb::Webhooks::EmbedImage.new(url: 'https://www.ruby-lang.org/images/header-ruby-logo.png')
end

Parameters:

  • message (String) (defaults to: '')

    The message that should be sent along with the embed. If this is the empty string, only the embed will be shown.

  • embed (Discordrb::Webhooks::Embed, nil) (defaults to: nil)

    The embed to start the building process with, or nil if one should be created anew.

  • attachments (Array<File>) (defaults to: nil)

    Files that can be referenced in embeds via attachment://file.png

  • tts (true, false) (defaults to: false)

    Whether or not this message should be sent using Discord text-to-speech.

  • allowed_mentions (Hash, Discordrb::AllowedMentions, false, nil) (defaults to: nil)

    Mentions that are allowed to ping on this message. false disables all pings

  • message_reference (Message, String, Integer, nil) (defaults to: nil)

    The message, or message ID, to reply to if any.

  • components (View, Array<Hash>) (defaults to: nil)

    Interaction components to associate with this message.

Yields:

  • (embed)

    Yields the embed to allow for easy building inside a block.

Yield Parameters:

Returns:

  • (Message)

    The resulting message.



394
395
396
397
398
399
400
401
# File 'lib/discordrb/data/channel.rb', line 394

def send_embed(message = '', embed = nil, attachments = nil, tts = false, allowed_mentions = nil, message_reference = nil, components = nil)
  embed ||= Discordrb::Webhooks::Embed.new
  view = Discordrb::Webhooks::View.new

  yield(embed, view) if block_given?

  send_message(message, tts, embed, attachments, allowed_mentions, message_reference, components || view.to_a)
end