Class: RubyCord::Message::Reference
- Inherits:
-
Object
- Object
- RubyCord::Message::Reference
- Defined in:
- lib/rubycord/message_meta.rb
Overview
Represents reference of message.
Instance Attribute Summary collapse
-
#channel_id ⇒ RubyCord::Snowflake
The channel ID.
-
#fail_if_not_exists ⇒ Boolean
(also: #fail_if_not_exists?)
Whether fail the request if the message is not found.
-
#guild_id ⇒ RubyCord::Snowflake
The guild ID.
-
#message_id ⇒ RubyCord::Snowflake
The message ID.
Class Method Summary collapse
-
.from_hash(data) ⇒ RubyCord::Message::Reference
Initialize a new reference from a hash.
Instance Method Summary collapse
-
#initialize(guild_id, channel_id, message_id, fail_if_not_exists: true) ⇒ Reference
constructor
Initialize a new reference.
- #inspect ⇒ Object
-
#to_hash ⇒ Hash
Convert the reference to a hash.
Constructor Details
#initialize(guild_id, channel_id, message_id, fail_if_not_exists: true) ⇒ Reference
Initialize a new reference.
61 62 63 64 65 66 |
# File 'lib/rubycord/message_meta.rb', line 61 def initialize(guild_id, channel_id, , fail_if_not_exists: true) @guild_id = guild_id @channel_id = channel_id @message_id = @fail_if_not_exists = fail_if_not_exists end |
Instance Attribute Details
#channel_id ⇒ RubyCord::Snowflake
Returns The channel ID.
45 46 47 |
# File 'lib/rubycord/message_meta.rb', line 45 def channel_id @channel_id end |
#fail_if_not_exists ⇒ Boolean Also known as: fail_if_not_exists?
Returns Whether fail the request if the message is not found.
49 50 51 |
# File 'lib/rubycord/message_meta.rb', line 49 def fail_if_not_exists @fail_if_not_exists end |
#guild_id ⇒ RubyCord::Snowflake
Returns The guild ID.
43 44 45 |
# File 'lib/rubycord/message_meta.rb', line 43 def guild_id @guild_id end |
#message_id ⇒ RubyCord::Snowflake
Returns The message ID.
47 48 49 |
# File 'lib/rubycord/message_meta.rb', line 47 def @message_id end |
Class Method Details
.from_hash(data) ⇒ RubyCord::Message::Reference
Initialize a new reference from a hash.
90 91 92 93 94 95 96 97 |
# File 'lib/rubycord/message_meta.rb', line 90 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
#inspect ⇒ Object
99 100 101 |
# File 'lib/rubycord/message_meta.rb', line 99 def inspect "#<#{self.class.name} #{@channel_id}/#{@message_id}>" end |
#to_hash ⇒ Hash
Convert the reference to a hash.
73 74 75 76 77 78 79 80 |
# File 'lib/rubycord/message_meta.rb', line 73 def to_hash { message_id: @message_id, channel_id: @channel_id, guild_id: @guild_id, fail_if_not_exists: @fail_if_not_exists } end |