Class: Discorb::Message::Reference

Inherits:
Object
  • Object
show all
Defined in:
lib/discorb/message_meta.rb

Overview

Represents reference of message.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(guild_id, channel_id, message_id, fail_if_not_exists: true) ⇒ Reference

Initialize a new reference.

Parameters:



60
61
62
63
64
65
# File 'lib/discorb/message_meta.rb', line 60

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

Instance Attribute Details

#channel_idDiscorb::Snowflake

Returns The channel ID.

Returns:



44
45
46
# File 'lib/discorb/message_meta.rb', line 44

def channel_id
  @channel_id
end

#fail_if_not_existsBoolean Also known as: fail_if_not_exists?

Returns Whether fail the request if the message is not found.

Returns:

  • (Boolean)

    Whether fail the request if the message is not found.



48
49
50
# File 'lib/discorb/message_meta.rb', line 48

def fail_if_not_exists
  @fail_if_not_exists
end

#guild_idDiscorb::Snowflake

Returns The guild ID.

Returns:



42
43
44
# File 'lib/discorb/message_meta.rb', line 42

def guild_id
  @guild_id
end

#message_idDiscorb::Snowflake

Returns The message ID.

Returns:



46
47
48
# File 'lib/discorb/message_meta.rb', line 46

def message_id
  @message_id
end

Class Method Details

.from_hash(data) ⇒ Discorb::Message::Reference

Initialize a new reference from a hash.

Parameters:

  • data (Hash)

    The hash.

Returns:

See Also:



89
90
91
92
93
94
95
96
# File 'lib/discorb/message_meta.rb', line 89

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

Instance Method Details

#inspectObject



98
99
100
# File 'lib/discorb/message_meta.rb', line 98

def inspect
  "#<#{self.class.name} #{@channel_id}/#{@message_id}>"
end

#to_hashHash

Convert the reference to a hash.

Returns:

  • (Hash)

    The hash.



72
73
74
75
76
77
78
79
# File 'lib/discorb/message_meta.rb', line 72

def to_hash
  {
    message_id: @message_id,
    channel_id: @channel_id,
    guild_id: @guild_id,
    fail_if_not_exists: @fail_if_not_exists
  }
end