class Discorb::Webhook::Message
Represents a webhook message.
Attributes
channel_id[R]
@return [Discorb::Snowflake] The ID of the channel.
guild_id[R]
@return [Discorb::Snowflake] The ID of the guild.
Public Class Methods
new(webhook, data, client = nil)
click to toggle source
@!visibility private
# File lib/discorb/webhook.rb, line 303 def initialize(webhook, data, client = nil) @client = client @webhook = webhook @data = data _set_data(data) end
Public Instance Methods
delete!()
click to toggle source
Deletes the message. @macro async @macro http
# File lib/discorb/webhook.rb, line 329 def delete! Async do @webhook.delete_message!(self).wait end end
edit(...)
click to toggle source
Edits the message. @macro async @macro http @macro edit
@param (see Webhook#edit_message
)
# File lib/discorb/webhook.rb, line 318 def edit(...) Async do @webhook.edit_message(self, ...).wait end end
Private Instance Methods
_set_data(data)
click to toggle source
# File lib/discorb/webhook.rb, line 337 def _set_data(data) @id = Snowflake.new(data[:id]) @type = Discorb::Message.message_type[data[:type]] @content = data[:content] @channel_id = Snowflake.new(data[:channel_id]) @author = Author.new(data[:author]) @attachments = data[:attachments].map { |a| Attachment.new(a) } @embeds = data[:embeds] ? data[:embeds].map { |e| Embed.new(data: e) } : [] @mentions = data[:mentions].map { |m| Mention.new(m) } @mention_roles = data[:mention_roles].map { |m| Snowflake.new(m) } @mention_everyone = data[:mention_everyone] @pinned = data[:pinned] @tts = data[:tts] @created_at = data[:edited_timestamp] && Time.iso8601(data[:timestamp]) @updated_at = data[:edited_timestamp] && Time.iso8601(data[:edited_timestamp]) @flags = Message::Flag.new(data[:flags]) @webhook_id = Snowflake.new(data[:webhook_id]) end