Class: MijDiscord::Events::Reaction

Inherits:
Generic show all
Defined in:
lib/mij-discord/events/message.rb

Instance Attribute Summary collapse

Attributes inherited from Generic

#bot

Instance Method Summary collapse

Methods inherited from EventBase

delegate_method, filter_match, inherited, #inspect, #trigger?

Constructor Details

#initialize(bot, data) ⇒ Reaction

Returns a new instance of Reaction.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/mij-discord/events/message.rb', line 123

def initialize(bot, data)
  super(bot)

  @message_id = data['message_id'].to_i
  @channel = @bot.channel(data['channel_id'])

  user_id, server = data['user_id'], @channel.server
  @user = server ? server.member(user_id) : @bot.user(user_id) if user_id

  if (emoji = data['emoji'])
    @emoji = server&.emoji(emoji['id'])
    @emoji ||= MijDiscord::Data::Emoji.new(emoji, nil)
  end
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



112
113
114
# File 'lib/mij-discord/events/message.rb', line 112

def channel
  @channel
end

#emojiObject (readonly)

Returns the value of attribute emoji.



108
109
110
# File 'lib/mij-discord/events/message.rb', line 108

def emoji
  @emoji
end

#message_idObject (readonly)

Returns the value of attribute message_id.



114
115
116
# File 'lib/mij-discord/events/message.rb', line 114

def message_id
  @message_id
end

#userObject (readonly)

Returns the value of attribute user.



110
111
112
# File 'lib/mij-discord/events/message.rb', line 110

def user
  @user
end

Instance Method Details

#messageObject



138
139
140
# File 'lib/mij-discord/events/message.rb', line 138

def message
  @channel.message(@message_id)
end