class Discorb::Gateway::ReactionEvent
Represents a reaction event.
Attributes
@macro client_cache @return [Discorb::Channel] The channel the message was sent in.
@return [Discorb::Snowflake] The ID of the channel the message was sent in.
@return [Hash] The raw data of the event.
@return [Discorb::UnicodeEmoji, Discorb::PartialEmoji] The emoji that was reacted with.
@macro client_cache @return [Discorb::Guild] The guild the message was sent in.
@return [Discorb::Snowflake] The ID of the guild the message was sent in.
@macro client_cache @return [Discorb::Member] The member who reacted.
@return [Discorb::Snowflake] The ID of the user who reacted.
@macro client_cache @return [Discorb::Message] The message the reaction was sent in.
@return [Discorb::Snowflake] The ID of the message.
@macro client_cache @return [Discorb::User] The user who reacted.
@return [Discorb::Snowflake] The ID of the user who reacted.
Public Class Methods
@!visibility private
# File lib/discorb/gateway.rb, line 58 def initialize(client, data) @client = client @data = data if data.key?(:user_id) @user_id = Snowflake.new(data[:user_id]) else @member_data = data[:member] end @channel_id = Snowflake.new(data[:channel_id]) @message_id = Snowflake.new(data[:message_id]) @guild_id = Snowflake.new(data[:guild_id]) @guild = client.guilds[data[:guild_id]] @channel = client.channels[data[:channel_id]] unless @guild.nil? @user = client.users[data[:user_id]] if data.key?(:user_id) unless @guild.nil? @member = if data.key?(:member) @guild.members[data[:member][:user][:id]] || Member.new(@client, @guild_id, data[:member][:user], data[:member]) else @guild.members[data[:user_id]] end end @message = client.messages[data[:message_id]] @emoji = data[:emoji][:id].nil? ? UnicodeEmoji.new(data[:emoji][:name]) : PartialEmoji.new(data[:emoji]) end
Public Instance Methods
Fetch the message. If message is cached, it will be returned. @macro async @macro http
@param [Boolean] force Whether to force fetching the message.
@return [Discorb::Message] The message.
# File lib/discorb/gateway.rb, line 94 def fetch_message(force: false) Async do next @message if !force && @message @message = @channel.fetch_message(@message_id).wait end end