diff options
author | 2023-04-01 15:45:04 -0400 | |
---|---|---|
committer | 2023-04-01 15:45:04 -0400 | |
commit | 32b8f8062720acbde87fa8f8994993addb875a7c (patch) | |
tree | 3d68f5ce987e9ac6532f2b9ae30c8f4e0f9d29fc | |
parent | Merge pull request #2503 from python-discord/update_ping_cooldown (diff) |
Ping help thread owner if thread closes without engagement.
Add logic to see if anyone other than the OP (or bots) engaged in a help thread when it closes for inactivity. Currently only looks at the last 10 messages. If not, includes a ping to the OP before the embed in the closing message.
-rw-r--r-- | bot/exts/help_channels/_channel.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 670a10446..63a83c8fa 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -46,8 +46,19 @@ async def _close_help_post(closed_post: discord.Thread, closing_reason: _stats.C """Close the help post and record stats.""" embed = discord.Embed(description=CLOSED_POST_MSG) embed.set_author(name=f"{POST_TITLE} closed", icon_url=CLOSED_POST_ICON_URL) - - await closed_post.send(embed=embed) + message = '' + + # Include a ping in the close message if no one else engages, to encourage them + # to read the guide for asking better questions + if closing_reason == _stats.ClosingReason.INACTIVE and closed_post.owner is not None: + participant_ids = { + message.author.id async for message in closed_post.history(limit=10, oldest_first=False) + if not message.author.bot + } + if participant_ids == {closed_post.owner_id}: + message += closed_post.owner.mention + + await closed_post.send(message, embed=embed) await closed_post.edit(archived=True, locked=True, reason="Locked a closed help post") _stats.report_post_count() |