From 2d8ec558a093353be2468b4658cfe34b33ef2af2 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Mon, 2 Oct 2023 11:10:12 +0100 Subject: [PATCH 1/2] Remove help cooldown role The new forum-based help system implements its own cooldown system which is currently set to restrict members to a new post every 2 minutes. This restriction in addition to the much higher allowance of threads in our server, means that this help cooldown role is no longer useful. In fact, it is detrimental. Discord, in its infinite wisdom, tied the ability to change a post's name and tags to the ability to the 'Send messages' permission, meaning users with the help cooldown role were unable to complete these actions. --- bot/constants.py | 1 - bot/exts/help_channels/_channel.py | 23 ++--------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/bot/constants.py b/bot/constants.py index 4e73fbe746..1ddb1748eb 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -141,7 +141,6 @@ class _Roles(EnvConfig, env_prefix="roles_"): legacy_help_channels_access: int = 1074780483776417964 contributors: int = 295488872404484098 - help_cooldown: int = 699189276025421825 partners: int = 323426753857191936 python_community: int = 458226413825294336 voice_verified: int = 764802720779337729 diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 7592882660..70a83702b3 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -4,7 +4,7 @@ import arrow import discord -from pydis_core.utils import members, scheduling +from pydis_core.utils import scheduling import bot from bot import constants @@ -69,19 +69,6 @@ async def _close_help_post(closed_post: discord.Thread, closing_reason: _stats.C _stats.report_post_count() await _stats.report_complete_session(closed_post, closing_reason) - poster = closed_post.owner - cooldown_role = closed_post.guild.get_role(constants.Roles.help_cooldown) - - if poster is None: - # We can't include the owner ID/name here since the thread only contains None - log.info( - f"Failed to remove cooldown role for owner of post ({closed_post.id}). " - f"The user is likely no longer on the server." - ) - return - - await members.handle_role_change(poster, poster.remove_roles, cooldown_role) - async def send_opened_post_message(post: discord.Thread) -> None: """Send the opener message in the new help post.""" @@ -159,9 +146,6 @@ async def help_post_opened(opened_post: discord.Thread, *, reopen: bool = False) await send_opened_post_message(opened_post) - cooldown_role = opened_post.guild.get_role(constants.Roles.help_cooldown) - await members.handle_role_change(opened_post.owner, opened_post.owner.add_roles, cooldown_role) - async def help_post_closed(closed_post: discord.Thread) -> None: """Apply archive logic to a manually closed help forum post.""" @@ -188,10 +172,7 @@ async def help_post_deleted(deleted_post_event: discord.RawThreadDeleteEvent) -> cached_post = deleted_post_event.thread if cached_post and not cached_post.archived: # If the post is in the bot's cache, and it was not archived before deleting, - # report a complete session and remove the cooldown. - poster = cached_post.owner - cooldown_role = cached_post.guild.get_role(constants.Roles.help_cooldown) - await members.handle_role_change(poster, poster.remove_roles, cooldown_role) + # report a complete session. await _stats.report_complete_session(cached_post, _stats.ClosingReason.DELETED) From ccdc8abb855cff099028dc497797be77b7835b3b Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Mon, 2 Oct 2023 11:13:52 +0100 Subject: [PATCH 2/2] Use custom role check to for title command This ensures that if the user doesn't have the defined role, the CheckFailure raised is handled locally the way we want, rather than relying on the error-handler code --- bot/exts/help_channels/_cog.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py index 2d2bc27aab..2e77351485 100644 --- a/bot/exts/help_channels/_cog.py +++ b/bot/exts/help_channels/_cog.py @@ -8,6 +8,7 @@ from bot.bot import Bot from bot.exts.help_channels import _caches, _channel, _message from bot.log import get_logger +from bot.utils.checks import has_any_role_check log = get_logger(__name__) @@ -108,7 +109,7 @@ async def rename_help_post(self, ctx: commands.Context, *, title: str) -> None: # Silently fail in channels other than help posts return - if not await commands.has_any_role(constants.Roles.helpers).predicate(ctx): + if not await has_any_role_check(ctx, constants.Roles.helpers): # Silently fail for non-helpers return