mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
refactor: group commands for miscellaneous and utilities cogs
Introduces group commands for both miscellaneous and utilities cogs, allowing users to access subcommands via `.miscellaneous <subcommand>` and `.utilities <subcommand>`. Adds embedded help messages and hybrid invocation logic for easier command management and user guidance.
This commit is contained in:
@@ -9,6 +9,27 @@ class Utilities(commands.GroupCog, name="utilities"):
|
||||
self.bot = bot
|
||||
super().__init__()
|
||||
|
||||
@commands.group(name="utilities", invoke_without_command=True)
|
||||
async def utilities_group(self, context: Context):
|
||||
embed = discord.Embed(
|
||||
title="Utilities Commands",
|
||||
description="Use `.utilities <subcommand>` or `/utilities <subcommand>`.",
|
||||
color=0x7289DA
|
||||
)
|
||||
embed.add_field(name="Available", value="translate", inline=False)
|
||||
await context.send(embed=embed)
|
||||
|
||||
async def _invoke_hybrid(self, context: Context, name: str, **kwargs):
|
||||
command = self.bot.get_command(name)
|
||||
if command is not None:
|
||||
await context.invoke(command, **kwargs)
|
||||
else:
|
||||
await context.send(f"Unknown utilities command: {name}")
|
||||
|
||||
@utilities_group.command(name="translate")
|
||||
async def utilities_group_translate(self, context: Context, text: str = None, to_lang: str = "en", from_lang: str = None):
|
||||
await self._invoke_hybrid(context, "translate", text=text, to_lang=to_lang, from_lang=from_lang)
|
||||
|
||||
@commands.hybrid_command(
|
||||
name="translate",
|
||||
description="Translate text to another language"
|
||||
|
||||
Reference in New Issue
Block a user