Skip to content

Commit

Permalink
Remove cooldown role (#2774)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLovering authored Oct 28, 2023
1 parent ae5345a commit 7d16687
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
1 change: 0 additions & 1 deletion bot/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 2 additions & 21 deletions bot/exts/help_channels/_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand All @@ -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)


Expand Down
3 changes: 2 additions & 1 deletion bot/exts/help_channels/_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 7d16687

Please sign in to comment.