Class: Discorb::Gateway::MessageUpdateEvent
- Inherits:
-
GatewayEvent
- Object
- GatewayEvent
- Discorb::Gateway::MessageUpdateEvent
- Defined in:
- lib/discorb/gateway.rb
Overview
Represents a MESSAGE_UPDATE
event.
Instance Attribute Summary collapse
-
#after -> Discorb::Message
readonly
The message after update.
-
#attachments -> Array<Discorb::Attachment>
readonly
The attachments in the message.
-
#before -> Discorb::Message
readonly
The message before update.
- #channel -> nil, Discorb::Channel readonly
-
#channel_id -> Discorb::Snowflake
readonly
The ID of the channel the message was sent in.
-
#content -> String
readonly
The new content of the message.
-
#embeds -> Array<Discorb::Embed>
readonly
The embeds in the message.
- #guild -> nil, Discorb::Guild readonly
-
#guild_id -> Discorb::Snowflake
readonly
The ID of the guild the message was sent in.
-
#id -> Discorb::Snowflake
readonly
The ID of the message.
-
#mention_everyone -> Boolean
readonly
Whether the message pings @everyone.
- #mention_roles -> nil, Array<Discorb::Role> readonly
-
#timestamp -> Time
readonly
The time the message was edited.
Instance Method Summary collapse
-
#fetch_message -> Async::Task<Discorb::Message>
Fetch the message.
-
#initialize(client, data, before, after) -> MessageUpdateEvent
constructor
A new instance of MessageUpdateEvent.
Methods inherited from GatewayEvent
Constructor Details
#initialize(client, data, before, after) -> MessageUpdateEvent
Returns a new instance of MessageUpdateEvent.
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/discorb/gateway.rb', line 337 def initialize(client, data, before, after) @client = client @data = data @before = before @after = after @id = Snowflake.new(data[:id]) @channel_id = Snowflake.new(data[:channel_id]) @guild_id = Snowflake.new(data[:guild_id]) if data.key?(:guild_id) @content = data[:content] @timestamp = Time.iso8601(data[:edited_timestamp]) @mention_everyone = data[:mention_everyone] @mention_roles = data[:mention_roles].map { |r| guild.roles[r] } if data.key?(:mention_roles) @attachments = data[:attachments].map { |a| Attachment.from_hash(a) } if data.key?(:attachments) @embeds = data[:embeds] ? data[:embeds].map { |e| Embed.from_hash(e) } : [] if data.key?(:embeds) end |
Instance Attribute Details
#after -> Discorb::Message (readonly)
Returns The message after update.
309 310 311 |
# File 'lib/discorb/gateway.rb', line 309 def after @after end |
#attachments -> Array<Discorb::Attachment> (readonly)
Returns The attachments in the message.
326 327 328 |
# File 'lib/discorb/gateway.rb', line 326 def @attachments end |
#before -> Discorb::Message (readonly)
Returns The message before update.
307 308 309 |
# File 'lib/discorb/gateway.rb', line 307 def before @before end |
#channel -> nil, Discorb::Channel (readonly)
This method returns an object from client cache. it will return nil
if the object is not in cache.
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/discorb/gateway.rb', line 337 def initialize(client, data, before, after) @client = client @data = data @before = before @after = after @id = Snowflake.new(data[:id]) @channel_id = Snowflake.new(data[:channel_id]) @guild_id = Snowflake.new(data[:guild_id]) if data.key?(:guild_id) @content = data[:content] @timestamp = Time.iso8601(data[:edited_timestamp]) @mention_everyone = data[:mention_everyone] @mention_roles = data[:mention_roles].map { |r| guild.roles[r] } if data.key?(:mention_roles) @attachments = data[:attachments].map { |a| Attachment.from_hash(a) } if data.key?(:attachments) @embeds = data[:embeds] ? data[:embeds].map { |e| Embed.from_hash(e) } : [] if data.key?(:embeds) end |
#channel_id -> Discorb::Snowflake (readonly)
Returns The ID of the channel the message was sent in.
313 314 315 |
# File 'lib/discorb/gateway.rb', line 313 def channel_id @channel_id end |
#content -> String (readonly)
Returns The new content of the message.
317 318 319 |
# File 'lib/discorb/gateway.rb', line 317 def content @content end |
#embeds -> Array<Discorb::Embed> (readonly)
Returns The embeds in the message.
328 329 330 |
# File 'lib/discorb/gateway.rb', line 328 def @embeds end |
#guild -> nil, Discorb::Guild (readonly)
This method returns an object from client cache. it will return nil
if the object is not in cache.
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/discorb/gateway.rb', line 337 def initialize(client, data, before, after) @client = client @data = data @before = before @after = after @id = Snowflake.new(data[:id]) @channel_id = Snowflake.new(data[:channel_id]) @guild_id = Snowflake.new(data[:guild_id]) if data.key?(:guild_id) @content = data[:content] @timestamp = Time.iso8601(data[:edited_timestamp]) @mention_everyone = data[:mention_everyone] @mention_roles = data[:mention_roles].map { |r| guild.roles[r] } if data.key?(:mention_roles) @attachments = data[:attachments].map { |a| Attachment.from_hash(a) } if data.key?(:attachments) @embeds = data[:embeds] ? data[:embeds].map { |e| Embed.from_hash(e) } : [] if data.key?(:embeds) end |
#guild_id -> Discorb::Snowflake (readonly)
Returns The ID of the guild the message was sent in.
315 316 317 |
# File 'lib/discorb/gateway.rb', line 315 def guild_id @guild_id end |
#id -> Discorb::Snowflake (readonly)
Returns The ID of the message.
311 312 313 |
# File 'lib/discorb/gateway.rb', line 311 def id @id end |
#mention_everyone -> Boolean (readonly)
Returns Whether the message pings @everyone.
321 322 323 |
# File 'lib/discorb/gateway.rb', line 321 def mention_everyone @mention_everyone end |
#mention_roles -> nil, Array<Discorb::Role> (readonly)
This method returns an object from client cache. it will return nil
if the object is not in cache.
324 325 326 |
# File 'lib/discorb/gateway.rb', line 324 def mention_roles @mention_roles end |
#timestamp -> Time (readonly)
Returns The time the message was edited.
319 320 321 |
# File 'lib/discorb/gateway.rb', line 319 def @timestamp end |
Instance Method Details
#fetch_message -> Async::Task<Discorb::Message>
Fetch the message.
365 366 367 368 369 |
# File 'lib/discorb/gateway.rb', line 365 def Async do channel.(@id).wait end end |