Added ksp commands

This commit is contained in:
Daniel Skýpala 2023-03-27 23:32:31 +02:00
parent 48d5cfc45a
commit 4fd525d912
3 changed files with 24 additions and 0 deletions

19
cogs/ksp.py Normal file
View 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))

View file

@ -8,6 +8,7 @@ bot = commands.Bot()
cogs_list = [
'basic',
'roles',
'ksp',
]
for cog in cogs_list:

4
utils/ksp_utils.py Normal file
View 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 ''}"