Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Threads Events #218

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/discordrb/bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
require 'discordrb/events/webhooks'
require 'discordrb/events/invites'
require 'discordrb/events/interactions'
require 'discordrb/events/threads'

require 'discordrb/api'
require 'discordrb/api/channel'
Expand Down Expand Up @@ -1593,16 +1594,16 @@ def handle_dispatch(type, data)
when :THREAD_CREATE
create_channel(data)

event = ThreadCreateEvent.new(data, bot)
event = ThreadCreateEvent.new(data, self)
raise_event(event)
when :THREAD_UPDATE
update_channel(data)

event = ThreadUpdateEvent.new(data, bot)
event = ThreadUpdateEvent.new(data, self)
raise_event(event)
when :THREAD_DELETE
channel_delete(data)
@thread_members.delete(data['id'])
@thread_members.delete(data['id']&.resolve_id)

# raise ThreadDeleteEvent
when :THREAD_LIST_SYNC
Expand All @@ -1613,12 +1614,12 @@ def handle_dispatch(type, data)
when :THREAD_MEMBER_UPDATE
ensure_thread_member(data)
when :THREAD_MEMBERS_UPDATE
data['added_members'].each do |added_member|
data['added_members']&.each do |added_member|
ensure_thread_member(added_member) if added_member['user_id']
end

data['removed_member_ids'].each do |member_id|
@thread_members[channel_id].delete(member_id)
data['removed_member_ids']&.each do |member_id|
@thread_members[data['id']&.resolve_id]&.delete(member_id&.resolve_id)
end

event = ThreadMembersUpdateEvent.new(data, self)
Expand Down