Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/commands/help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from discord import Color, Embed, Interaction, app_commands
from discord.ext import commands

if TYPE_CHECKING:
from src.main import AeBot


class HelpCog(commands.GroupCog, group_name="help"):
Comment thread
TitouanDor marked this conversation as resolved.
Outdated
def __init__(self, bot: AeBot):
self.bot = bot

@app_commands.command(
name="help",
description=(
"Affiche la liste des commandes avec"
" leurs sous-commandes et leurs description"
),
)
async def help(self, interaction: Interaction):
embed = Embed(title="Aide du bot", color=Color.blue())

for command in self.bot.tree.get_commands():
if isinstance(command, app_commands.Group) and command.commands:
subcommands = "\n".join(
f" /{command.name} {sub.name} - {sub.description}"
for sub in command.commands
)
embed.add_field(
name=f"/{command.name} (groupe)", value=subcommands, inline=False
)
else:
embed.add_field(
name=f"/{command.name}",
value=command.description or "Pas de description.",
Comment thread
TitouanDor marked this conversation as resolved.
Outdated
inline=False,
)

await interaction.response.send_message(embed=embed, ephemeral=True)
4 changes: 3 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from src.client import SithClient
from src.commands.admin import AdminCog
from src.commands.club import ClubCog
from src.commands.help import HelpCog
from src.commands.misc import MiscCog
from src.commands.news import NewsCog
from src.commands.role import RoleCog
Expand Down Expand Up @@ -40,11 +41,12 @@ async def setup_hook(self):
await self.add_cog(AdminCog(self))
await self.add_cog(MiscCog())
await self.add_cog(RoleCog(self))
await self.add_cog(HelpCog(self))

async def on_ready(self):
await self.wait_until_ready()
self.watched_guild = self.get_guild(self.settings.guild.id)
await self.change_presence(activity=Game(name="/help"))
await self.change_presence(activity=Game(name="/help help"))
self.logger.info(f"Bot ready to act on {self.watched_guild.name}")

async def on_command(self, ctx: Context):
Expand Down