Skip to content

Commit 2fb83b0

Browse files
committed
Fixes thread_auto_close execution when disabled.
This fixes the issue #3290 which caused threads to be auto-closed even if `thread_auto_close` has been disabled. There was also an issue that closed the thread when the user has responded to mods. The thread should stay open and only auto close when the staff has replied back.
1 parent 3c3608f commit 2fb83b0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

cogs/utility.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,20 @@ async def config_remove(self, ctx, *, key: str.lower):
873873
color=self.bot.main_color,
874874
description=f"`{key}` had been reset to default.",
875875
)
876+
877+
# Cancel exsisting active closures from thread_auto_close due to being disabled.
878+
if key == "thread_auto_close":
879+
closures = self.bot.config["closures"]
880+
for recipient_id, items in tuple(closures.items()):
881+
if items.get("auto_close", False) is True:
882+
self.bot.config["closures"].pop(recipient_id)
883+
await self.config.update()
884+
thread = await self.bot.threads.find(recipient_id=int(recipient_id))
885+
if thread:
886+
await thread.cancel_closure(all=True)
887+
else:
888+
self.bot.config["closures"].pop(recipient_id)
889+
await self.config.update()
876890
else:
877891
embed = discord.Embed(
878892
title="Error",

core/thread.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,6 +1811,8 @@ async def send(
18111811

18121812
if not note and from_mod:
18131813
self.bot.loop.create_task(self._restart_close_timer()) # Start or restart thread auto close
1814+
elif not note and not from_mod:
1815+
await self.cancel_closure(all=True)
18141816

18151817
if self.close_task is not None:
18161818
# cancel closing if a thread message is sent.

0 commit comments

Comments
 (0)