mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 03:40:11 +01:00
Renamed 'miscellaneous' and 'utilities' cog group names to 'misc' and 'utils', respectively. Added aliases for command groups and updated help descriptions and embed author icons for consistency and clarity.
46 lines
1.8 KiB
Python
46 lines
1.8 KiB
Python
import discord
|
|
from discord.ext import commands
|
|
from discord.ext.commands import Context
|
|
|
|
from .translate import translate_command
|
|
|
|
class Utilities(commands.GroupCog, name="utils"):
|
|
def __init__(self, bot) -> None:
|
|
self.bot = bot
|
|
super().__init__()
|
|
|
|
@commands.group(name="utilities", aliases=["utils"], invoke_without_command=True)
|
|
async def utilities_group(self, context: Context):
|
|
embed = discord.Embed(
|
|
title="Utilities Commands",
|
|
description="Use `.utils <subcommand>` or `/utils <subcommand>`.",
|
|
color=0x7289DA
|
|
)
|
|
embed.set_author(name="Utilities", icon_url="https://yes.nighty.works/raw/8VLDcg.webp")
|
|
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"
|
|
)
|
|
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'")
|