refactor(utility): make command group

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.
This commit is contained in:
neoarz
2025-09-28 23:35:39 -04:00
parent 3bc5ebe192
commit a5eff449eb
4 changed files with 45 additions and 25 deletions

View File

@@ -0,0 +1,23 @@
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'")