class Discorb::Message::Reference

Represents reference of message.

Attributes

channel_id[RW]

@return [Discorb::Snowflake] The channel ID.

fail_if_not_exists[RW]

@return [Boolean] Whether fail the request if the message is not found.

fail_if_not_exists?[RW]

@return [Boolean] Whether fail the request if the message is not found.

guild_id[RW]

@return [Discorb::Snowflake] The guild ID.

message_id[RW]

@return [Discorb::Snowflake] The message ID.

Public Class Methods

from_hash(data) click to toggle source

Initialize a new reference from a hash.

@param [Hash] data The hash.

@return [Discorb::Message::Reference] The reference. @see discord.com/developers/docs/resources/channel#message-reference-object

# File lib/discorb/message.rb, line 493
def self.from_hash(data)
  new(data[:guild_id], data[:channel_id], data[:message_id], fail_if_not_exists: data[:fail_if_not_exists])
end
new(guild_id, channel_id, message_id, fail_if_not_exists: true) click to toggle source

Initialize a new reference.

@param [Discorb::Snowflake] guild_id The guild ID. @param [Discorb::Snowflake] channel_id The channel ID. @param [Discorb::Snowflake] message_id The message ID. @param [Boolean] fail_if_not_exists Whether fail the request if the message is not found.

# File lib/discorb/message.rb, line 462
def initialize(guild_id, channel_id, message_id, fail_if_not_exists: true)
  @guild_id = guild_id
  @channel_id = channel_id
  @message_id = message_id
  @fail_if_not_exists = fail_if_not_exists
end

Public Instance Methods

to_hash() click to toggle source

Convert the reference to a hash.

@return [Hash] The hash.

# File lib/discorb/message.rb, line 474
def to_hash
  {
    message_id: @message_id,
    channel_id: @channel_id,
    guild_id: @guild_id,
    fail_if_not_exists: @fail_if_not_exists,
  }
end
Also aliased as: to_reference
to_reference()
Alias for: to_hash