Skip to content

Commit

Permalink
Notify help threads if the owner is no longer on the server.
Browse files Browse the repository at this point in the history
  • Loading branch information
wookie184 committed Apr 18, 2024
1 parent 4d6781c commit 3c7701a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bot/exts/help_channels/_cog.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -141,3 +143,17 @@ async def new_post_message_listener(self, message: discord.Message) -> None:

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} has left the server.")
with contextlib.suppress(discord.NotFound):
await thread.send(":warning: The owner of this post has left the server.")

0 comments on commit 3c7701a

Please sign in to comment.