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