Browse Source

Description for commands

news
Daniel Skýpala 2 years ago
parent
commit
7c89395f70
  1. 4
      cogs/basic.py
  2. 6
      cogs/ksp.py
  3. 20
      cogs/roles.py

4
cogs/basic.py

@ -5,11 +5,11 @@ class Basic(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
@discord.slash_command() @discord.slash_command(description="Greets the world.")
async def sayhello(self, ctx): async def sayhello(self, ctx):
await ctx.respond('Hello world!') await ctx.respond('Hello world!')
@discord.slash_command() @discord.slash_command(description="Sends the bot's latency.")
async def ping(self, ctx): async def ping(self, ctx):
await ctx.respond('My ping is {:.0f}ms'.format(self.bot.latency*1000), ephemeral=True) await ctx.respond('My ping is {:.0f}ms'.format(self.bot.latency*1000), ephemeral=True)

6
cogs/ksp.py

@ -6,8 +6,8 @@ class Ksp(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
@discord.slash_command() @discord.slash_command(description="Generates urls for given task.")
async def task(self, ctx, task_code): async def task(self, ctx, task_code: str):
await ctx.respond( await ctx.respond(
f'**{task_code}**\n' f'**{task_code}**\n'
f'Task: {task_link(task_code, solution=False)}\n' f'Task: {task_link(task_code, solution=False)}\n'
@ -15,7 +15,7 @@ class Ksp(commands.Cog):
ephemeral=True ephemeral=True
) )
@discord.slash_command() @discord.slash_command(description="Shows deadlines of currently running series.")
async def deadlines(self, ctx): async def deadlines(self, ctx):
a_deadlines = active_deadlines() a_deadlines = active_deadlines()
if len(a_deadlines) == 0: if len(a_deadlines) == 0:

20
cogs/roles.py

@ -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

Loading…
Cancel
Save