mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 11:40:12 +01:00
refactor(fun): command group with subcommands
Introduces a 'fun' command group with subcommands for coinflip, 8ball, minesweeper, randomfact, and rps. Provides an embed listing available subcommands and routes each to its respective handler for improved command organization.
This commit is contained in:
@@ -13,6 +13,44 @@ class Fun(commands.GroupCog, name="fun"):
|
|||||||
self.bot = bot
|
self.bot = bot
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
@commands.group(name="fun", invoke_without_command=True)
|
||||||
|
async def fun_group(self, context: Context):
|
||||||
|
embed = discord.Embed(
|
||||||
|
title="Fun Commands",
|
||||||
|
description="Use `.fun <subcommand>` or slash `/fun <subcommand>`.",
|
||||||
|
color=0x7289DA
|
||||||
|
)
|
||||||
|
embed.set_author(name="Fun", icon_url="https://yes.nighty.works/raw/eW5lLm.webp")
|
||||||
|
embed.add_field(name="Available", value="coinflip, 8ball, minesweeper, randomfact, rps", 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 fun command: {name}")
|
||||||
|
|
||||||
|
@fun_group.command(name="coinflip")
|
||||||
|
async def fun_group_coinflip(self, context: Context):
|
||||||
|
await self._invoke_hybrid(context, "coinflip")
|
||||||
|
|
||||||
|
@fun_group.command(name="8ball")
|
||||||
|
async def fun_group_8ball(self, context: Context, *, question: str):
|
||||||
|
await self._invoke_hybrid(context, "8ball", question=question)
|
||||||
|
|
||||||
|
@fun_group.command(name="minesweeper")
|
||||||
|
async def fun_group_minesweeper(self, context: Context):
|
||||||
|
await self._invoke_hybrid(context, "minesweeper")
|
||||||
|
|
||||||
|
@fun_group.command(name="randomfact")
|
||||||
|
async def fun_group_randomfact(self, context: Context):
|
||||||
|
await self._invoke_hybrid(context, "randomfact")
|
||||||
|
|
||||||
|
@fun_group.command(name="rps")
|
||||||
|
async def fun_group_rps(self, context: Context):
|
||||||
|
await self._invoke_hybrid(context, "rps")
|
||||||
|
|
||||||
@commands.hybrid_command(
|
@commands.hybrid_command(
|
||||||
name="coinflip",
|
name="coinflip",
|
||||||
description="Make a coin flip, but give your bet before."
|
description="Make a coin flip, but give your bet before."
|
||||||
|
|||||||
Reference in New Issue
Block a user