Class: DiscordRDA::MessageDeleteBulkEvent
- Inherits:
-
Event
- Object
- Event
- DiscordRDA::MessageDeleteBulkEvent
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 MessageDeleteBulkEvent.
605
606
607
|
# File 'lib/discord_rda/event/base.rb', line 605
def initialize(data, shard_id:)
super('MESSAGE_DELETE_BULK', data, shard_id: shard_id)
end
|
Instance Method Details
#author_ids ⇒ Object
629
630
631
|
# File 'lib/discord_rda/event/base.rb', line 629
def author_ids
messages.map { |m| m.author&.id }.compact.uniq
end
|
#bulk_delete? ⇒ Boolean
637
638
639
|
# File 'lib/discord_rda/event/base.rb', line 637
def bulk_delete?
count > 1
end
|
#channel_id ⇒ Object
613
614
615
|
# File 'lib/discord_rda/event/base.rb', line 613
def channel_id
@data['channel_id']
end
|
#count ⇒ Object
621
622
623
|
# File 'lib/discord_rda/event/base.rb', line 621
def count
message_ids.length
end
|
#guild_id ⇒ Object
617
618
619
|
# File 'lib/discord_rda/event/base.rb', line 617
def guild_id
@data['guild_id']
end
|
#jump_url(message_id) ⇒ Object
641
642
643
644
645
646
647
|
# File 'lib/discord_rda/event/base.rb', line 641
def jump_url(message_id)
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_ids ⇒ Object
609
610
611
|
# File 'lib/discord_rda/event/base.rb', line 609
def message_ids
@data['ids'] || []
end
|
#messages ⇒ Object
625
626
627
|
# File 'lib/discord_rda/event/base.rb', line 625
def messages
@messages ||= (@data['messages'] || []).map { |m| Message.new(m.merge('deleted' => true)) }
end
|
#messages_by_author ⇒ Object
633
634
635
|
# File 'lib/discord_rda/event/base.rb', line 633
def messages_by_author
messages.group_by { |m| m.author&.id }
end
|