Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show close reasons in close message #3240

Merged
merged 7 commits into from
Jan 18, 2025
Merged
22 changes: 16 additions & 6 deletions bot/exts/help_channels/_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

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

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

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

embed = discord.Embed(description=CLOSED_POST_MSG)
embed.set_author(name=f"{POST_TITLE} closed", icon_url=CLOSED_POST_ICON_URL)
close_title = "Python help channel closed"
if closing_reason == _stats.ClosingReason.CLEANUP:
close_title += " as OP left server"
elif closing_reason == _stats.ClosingReason.COMMAND:
close_title += f" with {constants.Bot.prefix}close"
elif closing_reason == _stats.ClosingReason.INACTIVE:
close_title += " for inactivity"
elif closing_reason == _stats.ClosingReason.NATIVE:
close_title += " using Discord native close action"


embed.set_author(name=close_title, icon_url=CLOSED_POST_ICON_URL)
message = ""

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

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

await _close_help_post(archived_post, _stats.ClosingReason.INACTIVE)
await _close_help_post(archived_post, _stats.ClosingReason.NATIVE)


async def help_post_deleted(deleted_post_event: discord.RawThreadDeleteEvent) -> None:
Expand Down
1 change: 1 addition & 0 deletions bot/exts/help_channels/_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ClosingReason(Enum):

COMMAND = "command"
INACTIVE = "auto.inactive"
NATIVE = "auto.native"
DELETED = "auto.deleted"
CLEANUP = "auto.cleanup"

Expand Down
Loading