Skip to content

Commit a6a104c

Browse files
authored
Merge pull request #3240 from python-discord/Show-close-reasons
Show close reasons in close message
2 parents 5a50fdc + b237eef commit a6a104c

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

bot/exts/help_channels/_channel.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
ASKING_GUIDE_URL = "https://pythondiscord.com/pages/asking-good-questions/"
1717
BRANDING_REPO_RAW_URL = "https://raw.githubusercontent.com/python-discord/branding"
18-
POST_TITLE = "Python help channel"
1918

2019
NEW_POST_MSG = """
2120
**Remember to:**
@@ -29,8 +28,8 @@
2928
NEW_POST_ICON_URL = f"{BRANDING_REPO_RAW_URL}/main/icons/checkmark/green-checkmark-dist.png"
3029

3130
CLOSED_POST_MSG = f"""
32-
This help channel has been closed and it's no longer possible to send messages here. \
33-
If your question wasn't answered, feel free to create a new post in <#{constants.Channels.python_help}>. \
31+
This help channel has been closed. \
32+
Feel free to create a new post in <#{constants.Channels.python_help}>. \
3433
To maximize your chances of getting a response, check out this guide on [asking good questions]({ASKING_GUIDE_URL}).
3534
"""
3635
CLOSED_POST_ICON_URL = f"{BRANDING_REPO_RAW_URL}/main/icons/zzz/zzz-dist.png"
@@ -48,7 +47,18 @@ async def _close_help_post(closed_post: discord.Thread, closing_reason: _stats.C
4847
closed_post = await get_or_fetch_channel(bot.instance, closed_post.id)
4948

5049
embed = discord.Embed(description=CLOSED_POST_MSG)
51-
embed.set_author(name=f"{POST_TITLE} closed", icon_url=CLOSED_POST_ICON_URL)
50+
close_title = "Python help channel closed"
51+
if closing_reason == _stats.ClosingReason.CLEANUP:
52+
close_title += " as OP left server"
53+
elif closing_reason == _stats.ClosingReason.COMMAND:
54+
close_title += f" with {constants.Bot.prefix}close"
55+
elif closing_reason == _stats.ClosingReason.INACTIVE:
56+
close_title += " for inactivity"
57+
elif closing_reason == _stats.ClosingReason.NATIVE:
58+
close_title += " using Discord native close action"
59+
60+
61+
embed.set_author(name=close_title, icon_url=CLOSED_POST_ICON_URL)
5262
message = ""
5363

5464
# Include a ping in the close message if no one else engages, to encourage them
@@ -83,7 +93,7 @@ async def send_opened_post_message(post: discord.Thread) -> None:
8393
color=constants.Colours.bright_green,
8494
description=NEW_POST_MSG,
8595
)
86-
embed.set_author(name=f"{POST_TITLE} opened", icon_url=NEW_POST_ICON_URL)
96+
embed.set_author(name="Python help channel opened", icon_url=NEW_POST_ICON_URL)
8797
embed.set_footer(text=NEW_POST_FOOTER)
8898
await post.send(embed=embed, content=post.owner.mention)
8999

@@ -130,7 +140,7 @@ async def help_post_archived(archived_post: discord.Thread) -> None:
130140
if thread_update.user.id == bot.instance.user.id:
131141
return
132142

133-
await _close_help_post(archived_post, _stats.ClosingReason.INACTIVE)
143+
await _close_help_post(archived_post, _stats.ClosingReason.NATIVE)
134144

135145

136146
async def help_post_deleted(deleted_post_event: discord.RawThreadDeleteEvent) -> None:

bot/exts/help_channels/_stats.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class ClosingReason(Enum):
1616

1717
COMMAND = "command"
1818
INACTIVE = "auto.inactive"
19+
NATIVE = "auto.native"
1920
DELETED = "auto.deleted"
2021
CLEANUP = "auto.cleanup"
2122

0 commit comments

Comments
 (0)