Class: Discordrb::Events::ThreadMembersUpdateEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/discordrb/events/threads.rb

Overview

Raised when members are added or removed from a thread.

Instance Attribute Summary collapse

Attributes inherited from Event

#bot

Instance Method Summary collapse

Constructor Details

#initialize(data, bot) ⇒ ThreadMembersUpdateEvent

Returns a new instance of ThreadMembersUpdateEvent.



74
75
76
77
78
79
80
81
# File 'lib/discordrb/events/threads.rb', line 74

def initialize(data, bot)
  @bot = bot
  @server = bot.server(data['guild_id'].to_i) if data['guild_id']
  @thread = data.is_a?(Discordrb::Channel) ? data : bot.channel(data['id'].to_i)
  @added_member_ids = data['added_members']&.map { |m| m['user_id']&.to_i } || []
  @removed_member_ids = data['removed_member_ids']&.map(&:resolve_id) || []
  @member_count = data['member_count']
end

Instance Attribute Details

#member_countInteger (readonly)

Returns:



70
71
72
# File 'lib/discordrb/events/threads.rb', line 70

def member_count
  @member_count
end

#removed_member_idsArray<Integer> (readonly)

Returns:



67
68
69
# File 'lib/discordrb/events/threads.rb', line 67

def removed_member_ids
  @removed_member_ids
end

#threadChannel (readonly)

Returns:



64
65
66
# File 'lib/discordrb/events/threads.rb', line 64

def thread
  @thread
end