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

Re-fetch help threads before closing #3228

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Re-fetch help threads before closing.
This ensures that the thread title is up-to-date. Previously, even if someone changed the title of the thread, the bot might prepend the lock emoji to an older version of the title.
  • Loading branch information
swfarnsworth committed Jan 4, 2025
commit 3df806ef67f2a2f8c021145186571cbca46b4ac1
4 changes: 4 additions & 0 deletions bot/exts/help_channels/_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import arrow
import discord
import pydis_core
from pydis_core.utils import scheduling
from pydis_core.utils.channel import get_or_fetch_channel

Expand Down Expand Up @@ -44,6 +45,9 @@ def is_help_forum_post(channel: discord.abc.GuildChannel) -> bool:

async def _close_help_post(closed_post: discord.Thread, closing_reason: _stats.ClosingReason) -> None:
"""Close the help post and record stats."""
# Get Thread with updated metadata (such as the title)
closed_post = await pydis_core.utils.channel.get_or_fetch_channel(bot.instance, closed_post.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
closed_post = await pydis_core.utils.channel.get_or_fetch_channel(bot.instance, closed_post.id)
closed_post = await get_or_fetch_channel(bot.instance, closed_post.id)

Looks like get_or_fetch_channel is already imported in this file, so we can drop the import pydis_core entirely


embed = discord.Embed(description=CLOSED_POST_MSG)
embed.set_author(name=f"{POST_TITLE} closed", icon_url=CLOSED_POST_ICON_URL)
message = ""
Expand Down
Loading