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.



76
77
78
79
80
81
82
83
84
# File 'lib/discordrb/events/threads.rb', line 76

def initialize(data, bot)
  @bot = bot
  @thread = data.is_a?(Discordrb::Channel) ? data : bot.channel(data['id'].to_i)
  @added_members = data['added_members']&.map do |member|
    data['guild_id'] ? bot.member(data['guild_id'], member['user_id']) : bot.user(member['user_id'])
  end || []
  @removed_member_ids = data['removed_member_ids']&.map(&:resolve_id) || []
  @member_count = data['member_count']
end

Instance Attribute Details

#added_membersArray<Member, User> (readonly)

Returns:



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

def added_members
  @added_members
end

#member_countInteger (readonly)

Returns:



72
73
74
# File 'lib/discordrb/events/threads.rb', line 72

def member_count
  @member_count
end

#removed_member_idsArray<Integer> (readonly)

Returns:



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

def removed_member_ids
  @removed_member_ids
end

#threadChannel (readonly)

Returns:



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

def thread
  @thread
end