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