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.



209
210
211
# File 'lib/discord_rda/event/base.rb', line 209

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

Instance Method Details

#authorObject



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

def author
  message.author
end

#channel_idObject



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

def channel_id
  message.channel_id
end

#contentObject



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

def content
  message.content
end

#guild_idObject



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

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

#mentions_bot?(bot_id) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#messageObject



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

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