Class: DiscordRDA::MessageCreateEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/discord_rda/event/base.rb

Instance Attribute Summary

Attributes inherited from Event

#data, #shard_id, #timestamp, #type

Instance Method Summary collapse

Methods inherited from Event

#created_at, #inspect, #to_h

Constructor Details

#initialize(data, shard_id:) ⇒ MessageCreateEvent

Returns a new instance of MessageCreateEvent.



214
215
216
# File 'lib/discord_rda/event/base.rb', line 214

def initialize(data, shard_id:)
  super('MESSAGE_CREATE', data, shard_id: shard_id)
end

Instance Method Details

#authorObject



222
223
224
# File 'lib/discord_rda/event/base.rb', line 222

def author
  message.author
end

#channel_idObject



226
227
228
# File 'lib/discord_rda/event/base.rb', line 226

def channel_id
  message.channel_id
end

#contentObject



234
235
236
# File 'lib/discord_rda/event/base.rb', line 234

def content
  message.content
end

#guild_idObject



230
231
232
# File 'lib/discord_rda/event/base.rb', line 230

def guild_id
  @data['guild_id'] ? Snowflake.new(@data['guild_id']) : nil
end

#mentions_bot?(bot_id) ⇒ Boolean

Returns:

  • (Boolean)


238
239
240
# File 'lib/discord_rda/event/base.rb', line 238

def mentions_bot?(bot_id)
  message.mentioned_users.any? { |u| u.id.to_s == bot_id.to_s }
end

#messageObject



218
219
220
# File 'lib/discord_rda/event/base.rb', line 218

def message
  @message ||= Message.new(@data)
end