@@ -642,21 +642,22 @@ def parse_thread_create(self, data):
642
642
self .dispatch ('thread_create' , thread )
643
643
644
644
def parse_thread_update (self , data ):
645
- guild = self ._get_guild (int (data ['guild_id' ]))
646
- thread = guild .get_channel (int (data ['id' ]))
647
- if not thread :
648
- thread = ThreadChannel (state = self , guild = guild , data = data )
649
- if isinstance (thread .parent_channel , ForumChannel ):
650
- post = ForumPost (state = self , guild = guild , data = data )
651
- guild ._add_post (post )
645
+ guild_id = int (data ['guild_id' ])
646
+ guild = self ._get_guild (guild_id )
647
+ if guild is not None :
648
+ thread_id = int (data ['id' ])
649
+ thread = guild .get_channel (thread_id )
650
+ if thread is not None :
651
+ old_thread = copy .copy (thread )
652
+ thread ._update (guild , data )
653
+ if isinstance (thread .parent_channel , ForumChannel ):
654
+ self .dispatch ('post_update' , old_thread , thread )
655
+ else :
656
+ self .dispatch ('thread_update' , old_thread , thread )
652
657
else :
653
- guild ._add_thread (thread )
654
- old_thread = copy .copy (thread )
655
- thread ._update (guild , data )
656
- if isinstance (thread .parent_channel , ForumChannel ):
657
- self .dispatch ('post_update' , old_thread , thread )
658
+ log .debug ('THREAD_UPDATE referencing an unknown channel ID: %s. Discarding.' , thread_id )
658
659
else :
659
- self . dispatch ( 'thread_update ' , old_thread , thread )
660
+ log . debug ( 'THREAD_UPDATE referencing an unknown guild ID: %s. Discarding. ' , guild_id )
660
661
661
662
def parse_thread_delete (self , data ):
662
663
guild = self ._get_guild (int (data ['guild_id' ]))
0 commit comments