maple/commands/link.py
Matyáš Caras 8d33c22f71
feat: start work on character quiz
fixed DB and added a link command that saves user's list to DB
2024-04-07 12:49:03 +02:00

22 lines
1.2 KiB
Python

from interactions import Extension, slash_command, SlashContext, slash_option, OptionType, SlashCommandChoice
from util.db import get_connection, add_user_connection
class LinkExtension(Extension):
@slash_command(name="link", description="Propojí tvůj účet s anime listem")
@slash_option(name="username", description="Uživatelské jméno", required=True, opt_type=OptionType.STRING)
@slash_option(name="service", description="Služba (Anilist, MyAnimeList atp.)", required=True,
opt_type=OptionType.STRING,
choices=[SlashCommandChoice(name="Anilist", value="anilist"), ])
async def link(self, ctx: SlashContext, username: str, service: str):
await ctx.defer()
if get_connection(ctx.author_id) is not None:
await ctx.respond(content="Tvůj účet je již propojen!", ephemeral=True)
return
r = add_user_connection(ctx.author_id, username, service)
if not r:
await ctx.respond(content="Nepodařilo se propojit tě.", ephemeral=True)
return
await ctx.respond(content="Tvůj účet byl úspěšně propojen.", ephemeral=True)
return