From ba4eaa968909302b74ac25b727ff4c868eb801ce Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Sat, 30 Dec 2023 21:06:37 -0800 Subject: [PATCH] Add translate command --- app/cogs/actual_utils.py | 21 +++++++++++++++++++++ app/requirements.txt | 1 + 2 files changed, 22 insertions(+) diff --git a/app/cogs/actual_utils.py b/app/cogs/actual_utils.py index e088371d..7832f9f1 100755 --- a/app/cogs/actual_utils.py +++ b/app/cogs/actual_utils.py @@ -9,6 +9,27 @@ class ActualUtils(commands.Cog): def __init__(self, bot): self.bot: commands.Bot = bot + @commands.slash_command( + guild_ids=None, + name="translate", + description="Translate a string", + ) + @option( + "query", + description="What you're tryna translate", + input_type="str", + requred=True, + ) + async def translate(self, ctx, query: str): + from googletrans import Translator + + translator = Translator() + + result = translator.translate(query, dest="en").text + + await ctx.defer() + await ctx.followup.send(result) + @commands.slash_command( guild_ids=None, name="youtube", diff --git a/app/requirements.txt b/app/requirements.txt index 8e034d61..36b4d79c 100755 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -1,6 +1,7 @@ beautifulsoup4 cmagick git+https://github.com/pycord-development/pycord@6a69f6683be41e0c983cd0621eab240e86d37086 +googletrans==4.0.0rc1 gTTS httpx humanfriendly