class Discorb::Gateway::MessageUpdateEvent

Represents a `MESSAGE_UPDATE` event.

Attributes

after[R]

@return [Discorb::Message] The message after update.

attachments[R]

@return [Array<Discorb::Attachment>] The attachments in the message.

before[R]

@return [Discorb::Message] The message before update.

channel_id[R]

@return [Discorb::Snowflake] The ID of the channel the message was sent in.

content[R]

@return [String] The new content of the message.

embeds[R]

@return [Array<Discorb::Embed>] The embeds in the message.

guild_id[R]

@return [Discorb::Snowflake] The ID of the guild the message was sent in.

id[R]

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

mention_everyone[R]

@return [Boolean] Whether the message pings @everyone.

mention_roles[R]

@macro client_cache @return [Array<Discorb::Role>] The roles mentioned in the message.

timestamp[R]

@return [Time] The time the message was edited.

Public Class Methods

new(client, data, before, after) click to toggle source

@!attribute [r] channel

@macro client_cache
@return [Discorb::Channel] The channel the message was sent in.

@!attribute [r] guild

@macro client_cache
@return [Discorb::Guild] The guild the message was sent in.
# File lib/discorb/gateway.rb, line 240
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

Public Instance Methods

channel() click to toggle source
# File lib/discorb/gateway.rb, line 256
def channel
  @client.channels[@channel_id]
end
fetch_message() click to toggle source

Fetch the message. @macro async @macro http

@return [Discorb::Message] The message.

# File lib/discorb/gateway.rb, line 269
def fetch_message
  Async do
    channel.fetch_message(@id).wait
  end
end
guild() click to toggle source
# File lib/discorb/gateway.rb, line 260
def guild
  @client.guilds[@guild_id]
end