Class: DiscordRDA::MessageDeleteEvent
- Inherits:
-
Event
- Object
- Event
- DiscordRDA::MessageDeleteEvent
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
Returns a new instance of MessageDeleteEvent.
552
553
554
|
# File 'lib/discord_rda/event/base.rb', line 552
def initialize(data, shard_id:)
super('MESSAGE_DELETE', data, shard_id: shard_id)
end
|
Instance Method Details
#author ⇒ Object
579
580
581
|
# File 'lib/discord_rda/event/base.rb', line 579
def author
@author ||= User.new(@data['author']) if @data['author']
end
|
#channel_id ⇒ Object
560
561
562
|
# File 'lib/discord_rda/event/base.rb', line 560
def channel_id
@data['channel_id']
end
|
#content ⇒ Object
583
584
585
|
# File 'lib/discord_rda/event/base.rb', line 583
def content
@data['content']
end
|
#dm? ⇒ Boolean
591
592
593
|
# File 'lib/discord_rda/event/base.rb', line 591
def dm?
guild_id.nil?
end
|
#guild? ⇒ Boolean
587
588
589
|
# File 'lib/discord_rda/event/base.rb', line 587
def guild?
!guild_id.nil?
end
|
#guild_id ⇒ Object
564
565
566
|
# File 'lib/discord_rda/event/base.rb', line 564
def guild_id
@data['guild_id']
end
|
#jump_url ⇒ Object
595
596
597
598
599
600
601
|
# File 'lib/discord_rda/event/base.rb', line 595
def jump_url
if guild_id
"https://discord.com/channels/#{guild_id}/#{channel_id}/#{message_id}"
else
"https://discord.com/channels/@me/#{channel_id}/#{message_id}"
end
end
|
#message ⇒ Object
568
569
570
571
572
573
574
575
576
577
|
# File 'lib/discord_rda/event/base.rb', line 568
def message
@message ||= begin
if @data['author'] || @data['content'] || @data['embeds']
Message.new(@data.merge('id' => message_id, 'deleted' => true))
else
nil
end
end
end
|
#message_id ⇒ Object
556
557
558
|
# File 'lib/discord_rda/event/base.rb', line 556
def message_id
@data['id']
end
|