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.
Constructor Details
#initialize(client, data, before, after) -> MessageUpdateEvent
Returns a new instance of MessageUpdateEvent.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/discorb/gateway.rb', line 249 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.new(a) } if data.key?(:attachments) @embeds = data[:embeds] ? data[:embeds].map { |e| Embed.new(data: e) } : [] if data.key?(:embeds) end |
Instance Attribute Details
#after -> Discorb::Message (readonly)
Returns The message after update.
221 222 223 |
# File 'lib/discorb/gateway.rb', line 221 def after @after end |
#attachments -> Array<Discorb::Attachment> (readonly)
Returns The attachments in the message.
238 239 240 |
# File 'lib/discorb/gateway.rb', line 238 def @attachments end |
#before -> Discorb::Message (readonly)
Returns The message before update.
219 220 221 |
# File 'lib/discorb/gateway.rb', line 219 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.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/discorb/gateway.rb', line 249 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.new(a) } if data.key?(:attachments) @embeds = data[:embeds] ? data[:embeds].map { |e| Embed.new(data: e) } : [] if data.key?(:embeds) end |
#channel_id -> Discorb::Snowflake (readonly)
Returns The ID of the channel the message was sent in.
225 226 227 |
# File 'lib/discorb/gateway.rb', line 225 def channel_id @channel_id end |
#content -> String (readonly)
Returns The new content of the message.
229 230 231 |
# File 'lib/discorb/gateway.rb', line 229 def content @content end |
#embeds -> Array<Discorb::Embed> (readonly)
Returns The embeds in the message.
240 241 242 |
# File 'lib/discorb/gateway.rb', line 240 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.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/discorb/gateway.rb', line 249 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.new(a) } if data.key?(:attachments) @embeds = data[:embeds] ? data[:embeds].map { |e| Embed.new(data: e) } : [] if data.key?(:embeds) end |
#guild_id -> Discorb::Snowflake (readonly)
Returns The ID of the guild the message was sent in.
227 228 229 |
# File 'lib/discorb/gateway.rb', line 227 def guild_id @guild_id end |
#id -> Discorb::Snowflake (readonly)
Returns The ID of the message.
223 224 225 |
# File 'lib/discorb/gateway.rb', line 223 def id @id end |
#mention_everyone -> Boolean (readonly)
Returns Whether the message pings @everyone.
233 234 235 |
# File 'lib/discorb/gateway.rb', line 233 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.
236 237 238 |
# File 'lib/discorb/gateway.rb', line 236 def mention_roles @mention_roles end |
#timestamp -> Time (readonly)
Returns The time the message was edited.
231 232 233 |
# File 'lib/discorb/gateway.rb', line 231 def @timestamp end |
Instance Method Details
#fetch_message -> Async::Task<Discorb::Message>
This is an asynchronous method, it will return a Async::Task
object. Use Async::Task#wait
to get the result.
This method calls HTTP request.
Fetch the message.
278 279 280 281 282 |
# File 'lib/discorb/gateway.rb', line 278 def Async do channel.(@id).wait end end |