mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
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:
23
cogs/utilities/__init__.py
Normal file
23
cogs/utilities/__init__.py
Normal 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'")
|
||||
Reference in New Issue
Block a user