mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 11:40:12 +01:00
Introduces a new 'utilities' cog and a 'translate' command for translating text between languages. Refactors the translate functionality from a class-based cog to a function-based command, updates bot and help modules to register the new cog, and ensures proper language autocomplete and error handling.
24 lines
750 B
Python
24 lines
750 B
Python
import discord
|
|
from discord.ext import commands
|
|
from discord.ext.commands import Context
|
|
|
|
from .translate import translate_command
|
|
|
|
class Utilities(commands.GroupCog, name="utilities"):
|
|
def __init__(self, bot) -> None:
|
|
self.bot = bot
|
|
super().__init__()
|
|
|
|
@commands.hybrid_command(
|
|
name="translate",
|
|
description="Translate text to another language"
|
|
)
|
|
async def translate(self, context, text: str = None, to_lang: str = "en", from_lang: str = None):
|
|
return await translate_command()(self, context, text=text, to_lang=to_lang, from_lang=from_lang)
|
|
|
|
async def setup(bot) -> None:
|
|
cog = Utilities(bot)
|
|
await bot.add_cog(cog)
|
|
|
|
bot.logger.info("Loaded extension 'utilities.translate'")
|