From 8ad36c8b426029815f1d798e9dfddbf60848d839 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 14 Dec 2023 21:26:23 -0500 Subject: [PATCH] fix(moderation): fixed blacklist add command --- moderation/moderation.py | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/moderation/moderation.py b/moderation/moderation.py index 1f6c0a5..f6b3919 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -1473,38 +1473,33 @@ class Moderation(commands.Cog): @moderationset_blacklist.command(name='add') @checks.admin() - async def moderationset_blacklist_add(self, ctx: commands.Context, role: discord.Role, duration: str = None): - """Add a role to the blacklist. - - Parameters - ----------- - role: discord.Role - What role are you adding a blacklist type for? - duration: str - How long should the target be blacklisted for?""" + async def moderationset_blacklist_add(self, ctx: commands.Context, role: discord.Role, duration: str): + """Add a role to the blacklist.""" blacklist_roles: list = await self.config.guild(ctx.guild).blacklist_roles() for blacklist_role in blacklist_roles: if role.id == blacklist_role['role']: await ctx.send("Role already has an associated blacklist type!") return + + try: + parsed_time = parse(sval=duration, as_timedelta=True, raise_exception=True) + except ValueError: + await ctx.send("Please provide a valid duration!") + return + blacklist_roles.append( { 'role': role.id, - 'duration': duration + 'duration': parsed_time } ) await self.config.guild(ctx.guild).blacklist_roles.set(blacklist_roles) - await ctx.send(f"Role {role.mention} added to blacklist.", allowed_mentions=discord.AllowedMentions.none()) + await ctx.send(f"Role {role.mention} added as a blacklist type.", allowed_mentions=discord.AllowedMentions.none()) @moderationset_blacklist.command(name='remove') @checks.admin() async def moderationset_blacklist_remove(self, ctx: commands.Context, role: discord.Role): - """Remove a role's blacklist type. - - Parameters - ----------- - role: discord.Role - What role are you removing a blacklist type for?""" + """Remove a role's blacklist type.""" blacklist_roles: list = await self.config.guild(ctx.guild).blacklist_roles() for blacklist_role in blacklist_roles: if role.id == blacklist_role['role']: