From ab1da9d28febac43ecbe4f3fc634aa3d1b03aba5 Mon Sep 17 00:00:00 2001 From: lifehackerhansol Date: Sun, 29 Sep 2024 19:02:40 -0700 Subject: [PATCH] soap: convert soap_check into cog_check The commands here are not meant to be used outside of this group of users. Further decorators such as `is_staff()` may be applied for individual commands. --- cogs/soap.py | 13 +++++++++---- utils/checks.py | 12 ------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/cogs/soap.py b/cogs/soap.py index 3c0e5913f..a4198f329 100644 --- a/cogs/soap.py +++ b/cogs/soap.py @@ -7,7 +7,7 @@ import discord from discord.ext import commands -from utils.checks import is_staff, soap_check +from utils.checks import is_staff, check_staff, InsufficientStaffRank if TYPE_CHECKING: from kurisu import Kurisu @@ -26,6 +26,14 @@ def __init__(self, bot: Kurisu): self.soaps_category: Optional[discord.CategoryChannel] = None self.bot.loop.create_task(self.setup_soap()) + async def cog_check(self, ctx: GuildContext): + author = ctx.author + if not check_staff(self.bot, 'Helper', author.id) and not check_staff(self.bot, 'Staff', author.id) and ( + self.bot.roles['crc'] not in author.roles) and (self.bot.roles['Small Help'] not in author.roles): + raise InsufficientStaffRank("You can't use this command.") + return False + return True + async def setup_soap(self): await self.bot.wait_until_all_ready() db_channel = await self.bot.configuration.get_channel_by_name('soaps') @@ -43,7 +51,6 @@ async def setsoaps(self, ctx: GuildContext, category: discord.CategoryChannel): self.soaps_category = category await ctx.send("Soaps category set.") - @soap_check() @commands.guild_only() @commands.command(aliases=["soup", "soap"]) async def createsoap(self, ctx: GuildContext, helpee: discord.Member): @@ -101,7 +108,6 @@ async def deletesoap(self, ctx: GuildContext, channels: commands.Greedy[discord. await ctx.send(f"Deleted :soap: {channel.name}.") await channel.delete() - @soap_check() @commands.guild_only() @commands.command() async def soapnormal(self, ctx: GuildContext): @@ -114,7 +120,6 @@ async def soapnormal(self, ctx: GuildContext): "Please let us know if the eShop functions or not." ) - @soap_check() @commands.guild_only() @commands.command() async def soaplottery(self, ctx: GuildContext): diff --git a/utils/checks.py b/utils/checks.py index b08ef7a5f..9b60b832f 100644 --- a/utils/checks.py +++ b/utils/checks.py @@ -65,18 +65,6 @@ async def predicate(ctx): return commands.check(predicate) -def soap_check(): - async def predicate(ctx): - author = ctx.author - if not check_staff(ctx.bot, 'Helper', author.id) and not check_staff(ctx.bot, 'Staff', author.id) and ( - ctx.bot.roles['crc'] not in author.roles) and (ctx.bot.roles['Small Help'] not in author.roles): - raise InsufficientStaffRank("You can't use this command.") - return False - return True - - return commands.check(predicate) - - def check_if_user_can_ready(): async def predicate(ctx): channel = ctx.channel