From 7d166871143e830e6747206258343d6987897be5 Mon Sep 17 00:00:00 2001 From: ChrisJL Date: Sat, 28 Oct 2023 07:09:44 +0100 Subject: [PATCH] Remove cooldown role (#2774) --- bot/constants.py | 1 - bot/exts/help_channels/_channel.py | 23 ++--------------------- bot/exts/help_channels/_cog.py | 3 ++- 3 files changed, 4 insertions(+), 23 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) 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