Skip to content

Commit 9ec6709

Browse files
committed
sqash
1 parent ce3b07c commit 9ec6709

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

src/commands/help.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING
4+
5+
from discord import Color, Embed, Interaction, app_commands
6+
from discord.ext import commands
7+
8+
if TYPE_CHECKING:
9+
from src.main import AeBot
10+
11+
12+
class HelpCog(commands.GroupCog, group_name="help"):
13+
def __init__(self, bot: AeBot):
14+
self.bot = bot
15+
16+
@app_commands.command(
17+
name="help",
18+
description=(
19+
"Affiche la liste des commandes avec"
20+
" leurs sous-commandes et leurs description"
21+
),
22+
)
23+
async def help(self, interaction: Interaction):
24+
embed = Embed(title="Aide du bot", color=Color.blue())
25+
26+
for command in self.bot.tree.get_commands():
27+
if isinstance(command, app_commands.Group) and command.commands:
28+
subcommands = "\n".join(
29+
f" /{command.name} {sub.name} - {sub.description}"
30+
for sub in command.commands
31+
)
32+
embed.add_field(
33+
name=f"/{command.name} (groupe)", value=subcommands, inline=False
34+
)
35+
else:
36+
embed.add_field(
37+
name=f"/{command.name}",
38+
value=command.description or "Pas de description.",
39+
inline=False,
40+
)
41+
42+
await interaction.response.send_message(embed=embed, ephemeral=True)

src/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from src.client import SithClient
1414
from src.commands.admin import AdminCog
1515
from src.commands.club import ClubCog
16+
from src.commands.help import HelpCog
1617
from src.commands.misc import MiscCog
1718
from src.commands.news import NewsCog
1819
from src.commands.role import RoleCog
@@ -40,11 +41,12 @@ async def setup_hook(self):
4041
await self.add_cog(AdminCog(self))
4142
await self.add_cog(MiscCog())
4243
await self.add_cog(RoleCog(self))
44+
await self.add_cog(HelpCog(self))
4345

4446
async def on_ready(self):
4547
await self.wait_until_ready()
4648
self.watched_guild = self.get_guild(self.settings.guild.id)
47-
await self.change_presence(activity=Game(name="/help"))
49+
await self.change_presence(activity=Game(name="/help help"))
4850
self.logger.info(f"Bot ready to act on {self.watched_guild.name}")
4951

5052
async def on_command(self, ctx: Context):

0 commit comments

Comments
 (0)