class Discordrb::Interactions::Message
A message partial for interactions.
Attributes
@return [Attachment]
@return [Integer]
@return [Array<Component>]
@return [String, nil] The content of the message.
@return [true, false]
@return [Time, nil]
@return [Array<Embed>]
@return [Integer]
@return [Integer]
@return [Interaction] The interaction that created this message.
@return [Array<User>]
@return [Hash, nil]
@return [true, false] Whether this message is pinned in the channel it belongs to.
@return [Time]
@return [true, false]
Public Class Methods
@!visibility private
# File lib/discordrb/data/interaction.rb, line 708 def initialize(data, bot, interaction) @data = data @bot = bot @interaction = interaction @content = data['content'] @channel_id = data['channel_id'].to_i @pinned = data['pinned'] @tts = data['tts'] @message_reference = data['message_reference'] @server_id = data['guild_id']&.to_i @timestamp = Time.parse(data['timestamp']) if data['timestamp'] @edited_timestamp = data['edited_timestamp'].nil? ? nil : Time.parse(data['edited_timestamp']) @edited = !@edited_timestamp.nil? @id = data['id'].to_i @author = bot.ensure_user(data['author'] || data['member']['user']) @attachments = [] @attachments = data['attachments'].map { |e| Attachment.new(e, self, @bot) } if data['attachments'] @embeds = [] @embeds = data['embeds'].map { |e| Embed.new(e, self) } if data['embeds'] @mentions = [] data['mentions']&.each do |element| @mentions << bot.ensure_user(element) end @mention_roles = data['mention_roles'] @mention_everyone = data['mention_everyone'] @flags = data['flags'] @pinned = data['pinned'] @components = data['components'].map { |component_data| Components.from_data(component_data, @bot) } if data['components'] end
Public Instance Methods
@return [Channel] The channel the interaction originates from. @raise [Errors::NoPermission] When the bot is not in the server associated with this interaction.
# File lib/discordrb/data/interaction.rb, line 762 def channel @bot.channel(@channel_id) end
Delete this message.
# File lib/discordrb/data/interaction.rb, line 774 def delete @interaction.delete_message(@id) end
Edit this message’s data. @param content (see Interaction#send_message
) @param embeds (see Interaction#send_message
) @param allowed_mentions (see Interaction#send_message
) @yieldparam (see Interaction#send_message
)
# File lib/discordrb/data/interaction.rb, line 783 def edit(content: nil, embeds: nil, allowed_mentions: nil, components: nil, &block) @interaction.edit_message(@id, content: content, embeds: embeds, allowed_mentions: allowed_mentions, components: components, &block) end
@!visibility private
# File lib/discordrb/data/interaction.rb, line 795 def inspect "<Interaction::Message content=#{@content.inspect} embeds=#{@embeds.inspect} channel_id=#{@channel_id} server_id=#{@server_id} author=#{@author.inspect}>" end
@return [Member, nil] This will return nil if the bot does not have access to the
server the interaction originated in.
# File lib/discordrb/data/interaction.rb, line 750 def member server&.member(@user.id) end
Respond to this message. @param (see Interaction#send_message
) @yieldparam (see Interaction#send_message
)
# File lib/discordrb/data/interaction.rb, line 769 def respond(content: nil, embeds: nil, allowed_mentions: nil, flags: 0, ephemeral: true, components: nil, &block) @interaction.send_message(content: content, embeds: embeds, allowed_mentions: allowed_mentions, flags: flags, ephemeral: ephemeral, components: components, &block) end
@return [Server, nil] This will return nil if the bot does not have access to the
server the interaction originated in.
# File lib/discordrb/data/interaction.rb, line 756 def server @bot.server(@server_id) end
@return [Discordrb::Message]
# File lib/discordrb/data/interaction.rb, line 788 def to_message Discordrb::Message.new(@data, @bot) end