aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar wookie184 <[email protected]>2024-04-29 00:43:42 +0100
committerGravatar GitHub <[email protected]>2024-04-28 23:43:42 +0000
commitbbfb333958a5093168510eb88b2aa65752c55aa1 (patch)
tree5442d82f2465e2ec4437f12f86acf2305ba24128
parentUpdate system-python.md: Improve bullet point formatting (#3029) (diff)
Notify help threads if the owner is no longer on the server (#3022)
Co-authored-by: ~hedy <[email protected]>
-rw-r--r--bot/exts/help_channels/_cog.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py
index 96c0a89ba..0e0274255 100644
--- a/bot/exts/help_channels/_cog.py
+++ b/bot/exts/help_channels/_cog.py
@@ -1,5 +1,7 @@
"""Contains the Cog that receives discord.py events and defers most actions to other files in the module."""
+import contextlib
+
import discord
from discord.ext import commands, tasks
from pydis_core.utils import scheduling
@@ -141,3 +143,17 @@ class HelpForum(commands.Cog):
if not message.author.bot and message.author.id != message.channel.owner_id:
await _caches.posts_with_non_claimant_messages.set(message.channel.id, "sentinel")
+
+ @commands.Cog.listener()
+ async def on_member_remove(self, member: discord.Member) -> None:
+ """Notify a help thread if the owner is no longer a member of the server."""
+ for thread in self.help_forum_channel.threads:
+ if thread.owner_id != member.id:
+ continue
+
+ if thread.archived:
+ continue
+
+ log.debug(f"Notifying help thread {thread.id} that owner {member.id} is no longer in the server.")
+ with contextlib.suppress(discord.NotFound):
+ await thread.send(":warning: The owner of this post is no longer in the server.")