didier/cogs/slash/translate_slash.py

24 lines
1018 B
Python
Raw Normal View History

2021-09-03 18:53:05 +02:00
from discord.ext import commands
2022-02-03 01:43:54 +01:00
from discord.commands import slash_command, ApplicationContext, Option
2021-09-03 18:53:05 +02:00
from data.embeds.translate import Translation
from startup.didier import Didier
class TranslateSlash(commands.Cog):
def __init__(self, client: Didier):
self.client: Didier = client
2022-02-03 01:43:54 +01:00
@slash_command(name="translate", description="Google Translate")
async def _translate_slash(self, ctx: ApplicationContext,
text: Option(str, description="Tekst om te vertalen"),
from_lang: Option(str, description="Taal om van te vertalen (default auto-detect)", default="auto"),
to_lang: Option(str, description="Taal om naar te vertalen (default NL)", default="nl")
):
translation = Translation(text=text, fr=from_lang.lower(), to=to_lang.lower())
2022-02-03 01:43:54 +01:00
await ctx.respond(embed=translation.to_embed())
2021-09-03 18:53:05 +02:00
def setup(client: Didier):
client.add_cog(TranslateSlash(client))