|
|
@ -11,11 +11,14 @@ class Roles(commands.Cog): |
|
|
|
|
|
|
|
secret_roles = discord.SlashCommandGroup( |
|
|
|
"secretroles", |
|
|
|
"Commands for management of secret roles.", |
|
|
|
checks=[commands.has_permissions(manage_roles=True)] |
|
|
|
) |
|
|
|
|
|
|
|
@secret_roles.command() |
|
|
|
async def add(self, ctx, role: discord.role.Role, password: str): |
|
|
|
@secret_roles.command(description="Adds a new secret role.") |
|
|
|
@discord.option("role", discord.role.Role, description="Role locked behind a password.") |
|
|
|
@discord.option("password", str, description="Password for given role.") |
|
|
|
async def add(self, ctx, role, password): |
|
|
|
roles = data.load_data(ROLES_JSON) |
|
|
|
if password in roles["secret_roles"]: |
|
|
|
return await ctx.respond(f"Password ``{password}`` is already used.", ephemeral=True) |
|
|
@ -24,7 +27,7 @@ class Roles(commands.Cog): |
|
|
|
data.dump_data(ROLES_JSON, roles) |
|
|
|
return await ctx.respond(f"Secret role {role.mention} added with password {password}.", ephemeral=True) |
|
|
|
|
|
|
|
@secret_roles.command() |
|
|
|
@secret_roles.command(description="Lists all passwords and their secret roles") |
|
|
|
async def list(self, ctx): |
|
|
|
roles = data.load_data(ROLES_JSON) |
|
|
|
if len(roles["secret_roles"]) == 0: |
|
|
@ -35,8 +38,9 @@ class Roles(commands.Cog): |
|
|
|
msg += f"``{passwd}``: {role.mention}\n" |
|
|
|
return await ctx.respond(msg, ephemeral=True) |
|
|
|
|
|
|
|
@secret_roles.command() |
|
|
|
async def delete(self, ctx, password: str): |
|
|
|
@secret_roles.command(description="Deletes given password and its secret role.") |
|
|
|
@discord.option("password", str, description="Password to be deleted.") |
|
|
|
async def delete(self, ctx, password): |
|
|
|
roles = data.load_data(ROLES_JSON) |
|
|
|
if password not in roles["secret_roles"]: |
|
|
|
return await ctx.respond(f"Role with passowrd {password} does not exist.", ephemeral=True) |
|
|
@ -49,9 +53,9 @@ class Roles(commands.Cog): |
|
|
|
ephemeral=True |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
@discord.slash_command() |
|
|
|
async def secretrole(self, ctx, password: str): |
|
|
|
@discord.slash_command(description="Gives a secret role locked by a password.") |
|
|
|
@discord.option("password", str, description="Password for secret role.") |
|
|
|
async def secretrole(self, ctx, password): |
|
|
|
roles = data.load_data(ROLES_JSON) |
|
|
|
if password in roles["secret_roles"]: |
|
|
|
author = ctx.author |
|
|
|