Class: Discorb::Gateway::ReactionEvent

Inherits:
GatewayEvent show all
Defined in:
lib/discorb/gateway.rb

Overview

Represents a reaction event.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from GatewayEvent

#inspect

Instance Attribute Details

#channel -> nil, Discorb::Channel (readonly)

Note:

This method returns an object from client cache. it will return nil if the object is not in cache.

Returns:

  • (nil)

    The object wasn't cached.

  • (Discorb::Channel)

    The channel the message was sent in.



55
56
57
# File 'lib/discorb/gateway.rb', line 55

def channel
  @channel
end

#channel_id -> Discorb::Snowflake (readonly)

Returns The ID of the channel the message was sent in.

Returns:



45
46
47
# File 'lib/discorb/gateway.rb', line 45

def channel_id
  @channel_id
end

#data -> Hash (readonly)

Returns The raw data of the event.

Returns:

  • (Hash)

    The raw data of the event.



40
41
42
# File 'lib/discorb/gateway.rb', line 40

def data
  @data
end

#emoji -> Discorb::UnicodeEmoji, Discorb::PartialEmoji (readonly)

Returns The emoji that was reacted with.

Returns:



66
67
68
# File 'lib/discorb/gateway.rb', line 66

def emoji
  @emoji
end

#fired_by -> nil, ... (readonly) Also known as: reactor, from

Note:

This method returns an object from client cache. it will return nil if the object is not in cache.

Returns:



69
70
71
# File 'lib/discorb/gateway.rb', line 69

def fired_by
  @fired_by
end

#guild -> nil, Discorb::Guild (readonly)

Note:

This method returns an object from client cache. it will return nil if the object is not in cache.

Returns:

  • (nil)

    The object wasn't cached.

  • (Discorb::Guild)

    The guild the message was sent in.



58
59
60
# File 'lib/discorb/gateway.rb', line 58

def guild
  @guild
end

#guild_id -> Discorb::Snowflake (readonly)

Returns The ID of the guild the message was sent in.

Returns:



49
50
51
# File 'lib/discorb/gateway.rb', line 49

def guild_id
  @guild_id
end

#member -> nil, Discorb::Member (readonly)

Note:

This method returns an object from client cache. it will return nil if the object is not in cache.

Returns:

  • (nil)

    The object wasn't cached.

  • (Discorb::Member)

    The member who reacted.



64
65
66
# File 'lib/discorb/gateway.rb', line 64

def member
  @member
end

#message -> nil, Discorb::Message (readonly)

Note:

This method returns an object from client cache. it will return nil if the object is not in cache.

Returns:

  • (nil)

    The object wasn't cached.

  • (Discorb::Message)

    The message the reaction was sent in.



61
62
63
# File 'lib/discorb/gateway.rb', line 61

def message
  @message
end

#message_id -> Discorb::Snowflake (readonly)

Returns The ID of the message.

Returns:



47
48
49
# File 'lib/discorb/gateway.rb', line 47

def message_id
  @message_id
end

#user -> nil, Discorb::User (readonly)

Note:

This method returns an object from client cache. it will return nil if the object is not in cache.

Returns:

  • (nil)

    The object wasn't cached.

  • (Discorb::User)

    The user who reacted.



52
53
54
# File 'lib/discorb/gateway.rb', line 52

def user
  @user
end

#user_id -> Discorb::Snowflake (readonly) Also known as: member_id

Returns The ID of the user who reacted.

Returns:



42
43
44
# File 'lib/discorb/gateway.rb', line 42

def user_id
  @user_id
end

Instance Method Details

#fetch_message(force: false) -> Async::Task<Discorb::Message>

Fetch the message. If message is cached, it will be returned.

Parameters:

  • force (Boolean) (defaults to: false)

    Whether to force fetching the message.

Returns:



119
120
121
122
123
124
125
# File 'lib/discorb/gateway.rb', line 119

def fetch_message(force: false)
  Async do
    next @message if !force && @message

    @message = @channel.fetch_message(@message_id).wait
  end
end