Fix channel deletion not removing associated threads

This commit is contained in:
Lilly Rose Berner
2024-05-05 05:23:59 +02:00
committed by GitHub
parent 0b4263e697
commit 0ee1794c6d
3 changed files with 27 additions and 4 deletions

View File

@ -378,10 +378,11 @@ class Guild(Hashable):
def _clear_threads(self) -> None:
self._threads.clear()
def _remove_threads_by_channel(self, channel_id: int) -> None:
to_remove = [k for k, t in self._threads.items() if t.parent_id == channel_id]
for k in to_remove:
del self._threads[k]
def _remove_threads_by_channel(self, channel_id: int) -> List[Thread]:
to_remove = [t for t in self._threads.values() if t.parent_id == channel_id]
for thread in to_remove:
del self._threads[thread.id]
return to_remove
def _filter_threads(self, channel_ids: Set[int]) -> Dict[int, Thread]:
to_remove: Dict[int, Thread] = {k: t for k, t in self._threads.items() if t.parent_id in channel_ids}