fix(moderation): fixed blacklist add command
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 48s

This commit is contained in:
Seaswimmer 2023-12-14 21:26:23 -05:00
parent 0630804267
commit 8ad36c8b42
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -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']: