Added ksp commands
This commit is contained in:
parent
48d5cfc45a
commit
4fd525d912
3 changed files with 24 additions and 0 deletions
19
cogs/ksp.py
Normal file
19
cogs/ksp.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import discord
|
||||
from discord.ext import commands
|
||||
from utils.ksp_utils import *
|
||||
|
||||
class Ksp(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@discord.slash_command()
|
||||
async def task(self, ctx, task_code):
|
||||
await ctx.respond(
|
||||
f'**{task_code}**\n'
|
||||
f'Task: {task_link(task_code, solution=False)}\n'
|
||||
f'Solution: {task_link(task_code, solution=True)}',
|
||||
ephemeral=True
|
||||
)
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Ksp(bot))
|
1
main.py
1
main.py
|
@ -8,6 +8,7 @@ bot = commands.Bot()
|
|||
cogs_list = [
|
||||
'basic',
|
||||
'roles',
|
||||
'ksp',
|
||||
]
|
||||
|
||||
for cog in cogs_list:
|
||||
|
|
4
utils/ksp_utils.py
Normal file
4
utils/ksp_utils.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
KSP_URL = "https://ksp.mff.cuni.cz"
|
||||
|
||||
def task_link(task_code: str, solution : bool = False):
|
||||
return f"{KSP_URL}/viz/{task_code}/{'reseni' if solution else ''}"
|
Loading…
Reference in a new issue