Skip to content

Commit ddbe77f

Browse files
committed
MAJ des commandes et de help
1 parent c6ce837 commit ddbe77f

File tree

3 files changed

+85
-94
lines changed

3 files changed

+85
-94
lines changed

app/_app.py

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from discord import app_commands
22
import asyncio
3-
from config import os, bot, tree, logger,discord, TOKEN
4-
from tools import help, clear_slash,start_Session,Wait,presentation_bot
3+
from config import os, bot, tree, logger, discord, TOKEN
4+
from tools import help, clear_slash, start_Session, Wait, presentation_bot
55
import error_embed as embed
66
import classement as ldb
77
from admin_command import ban
@@ -23,28 +23,6 @@ async def on_ready():
2323
# _______________________________________________________________________________________________________________________________
2424

2525

26-
@tree.command(name="ping", description="Répond avec Pong !")
27-
async def ping_slash(interaction: discord.Interaction):
28-
await interaction.response.send_message("🏓 Pong !")
29-
30-
# _______________________________________________________________________________________________________________________________
31-
32-
33-
@tree.command(name="say", description="Répète ton message")
34-
@app_commands.describe(message="Le message à répéter")
35-
async def say_slash(interaction: discord.Interaction, message: str):
36-
await interaction.response.send_message(f"💬 {message}")
37-
38-
# _______________________________________________________________________________________________________________________________
39-
40-
41-
@tree.command(name="salut", description="Salue quelqu’un")
42-
async def salut_slash(interaction: discord.Interaction):
43-
await interaction.response.send_message(f"👋 Salut {interaction.user.mention} !")
44-
45-
# _______________________________________________________________________________________________________________________________
46-
47-
4826
@tree.command(name="clear", description="Supprime des messages (admin uniquement)")
4927
@app_commands.describe(nombre="Nombre de messages à supprimer")
5028
async def clearing_tool(interaction: discord.Interaction, nombre: int):
@@ -85,6 +63,7 @@ async def submit(interaction: discord.Interaction, premier: str, deuxieme: str,
8563

8664
# _______________________________________________________________________________________________________________________________
8765

66+
8867
@tree.command(name="pronos_qualif", description="Enregistre tes pronos ou modifie les si tu l'a déja fait par le passé(max 1 fois)")
8968
@app_commands.describe(premier="Le premier", deuxieme="Le deuxième", troisieme="Le troisième")
9069
async def submit_qualif(interaction: discord.Interaction, premier: str, deuxieme: str, troisieme: str):
@@ -112,34 +91,38 @@ async def submit_qualif(interaction: discord.Interaction, premier: str, deuxieme
11291

11392
# _______________________________________________________________________________________________________________________________
11493

94+
11595
@tree.command(name="visualisation", description="Te montre tes pronos")
116-
async def visu(interaction : discord.Interaction):
96+
async def visu(interaction: discord.Interaction):
11797
await interaction.response.defer(ephemeral=True)
11898
await pr.visualisation(interaction)
11999
# _______________________________________________________________________________________________________________________________
120100

101+
121102
@tree.command(name="leaderboard", description="Affiche le clasement des membres")
122103
async def leaderboard(interaction: discord.Interaction):
123104
await interaction.response.defer()
124105
embed = ldb.Leaderboard()
125-
await interaction.followup.send(content=None,embed=embed)
106+
await interaction.followup.send(content=None, embed=embed)
126107
logger.info(f'{interaction.user} à regarder le leaderbord')
127-
108+
128109
# _______________________________________________________________________________________________________________________________
129-
110+
111+
130112
@tree.command(name="admin_ban", description="AC-03")
131-
@app_commands.describe(member= "Membre à bannnir", reason = "Raison du bannissement" , article = "Le ou les articles qu'il a enfreint")
113+
@app_commands.describe(member="Membre à bannnir", reason="Raison du bannissement", article="Le ou les articles qu'il a enfreint")
132114
async def bannissement(interaction: discord.Interaction, member: discord.Member, reason: str, article: str):
133115
if interaction.user.guild_permissions.ban_members:
134116
await interaction.response.defer(ephemeral=True)
135117
await ban(interaction, member, reason, article)
136118
logger.info(f"{interaction.user.name} à banni {member}")
137-
119+
138120
else:
139121
await embed.chat_you_dont_have_perm(interaction)
140-
122+
141123
# _______________________________________________________________________________________________________________________________
142-
124+
125+
143126
@tree.command(name="admin_open", description="Ouvre une session de pronostics pour un temp donné")
144127
@app_commands.describe(duration="temps en heures")
145128
async def create(interaction: discord.Interaction, duration: float):
@@ -160,9 +143,10 @@ async def create(interaction: discord.Interaction, duration: float):
160143
else:
161144
await interaction.response.defer(ephemeral=True)
162145
await interaction.followup.send(embed=await embed.permError(interaction))
163-
146+
164147
# _______________________________________________________________________________________________________________________________
165148

149+
166150
@tree.command(name="admin_close", description="Ferme la session de pronos")
167151
async def close(interaction: discord.Interaction):
168152
await interaction.response.defer(ephemeral=True)
@@ -187,6 +171,7 @@ async def close(interaction: discord.Interaction):
187171

188172
# _______________________________________________________________________________________________________________________________
189173

174+
190175
@tree.command(name="session", description="Configure manuellement la session des pronos récupère ses résultats, et update le leaderboard")
191176
@app_commands.describe(saison="Année de la saison", location="Nom du Circuit", type="Type de l'événement(Q pour qualif, ou R pour course)")
192177
async def session(interaction: discord.Interaction, saison: int, location: str, type: str):
@@ -211,15 +196,16 @@ async def session(interaction: discord.Interaction, saison: int, location: str,
211196
await interaction.followup.send("Le Leaderboard est à jour")
212197
else:
213198
await interaction.followup.send(embed=await embed.permError(interaction))
214-
199+
215200
# _______________________________________________________________________________________________________________________________
216201

202+
217203
@tree.command(name="admin_getresult", description="Mettre à jour l'api")
218204
async def maj_api(interaction: discord.Interaction):
219205
interaction.response.defer()
220206
if interaction.user.guild_permissions.administrator:
221207
await interaction.response.send_message("⏳ Mise à jour en cours...")
222-
208+
223209
try:
224210
result = f1api.getResults()
225211

@@ -256,6 +242,7 @@ async def status(interaction: discord.Interaction):
256242

257243
# _______________________________________________________________________________________________________________________________
258244

245+
259246
@tree.command(name="admin_stop", description="Stop le fonctionnement auto du bot")
260247
async def stop(interaction: discord.Interaction):
261248
await interaction.response.defer(ephemeral=True)
@@ -310,6 +297,8 @@ async def auto_mod(interaction: discord.Interaction):
310297
ldb.saveResults()
311298
if (os.path.exists("data/Pronos.json")):
312299
os.remove("data/Pronos.json")
300+
301+
313302
@tree.command(name="admin_launch", description="Lance le fonctionnement auto du bot")
314303
async def launch(interaction: discord.Interaction):
315304
if interaction.user.guild_permissions.administrator:
@@ -320,9 +309,10 @@ async def launch(interaction: discord.Interaction):
320309
else:
321310
await interaction.response.defer(ephemeral=True)
322311
await interaction.followup.send(embed=await embed.permError(interaction), ephemeral=True)
323-
312+
324313
# _______________________________________________________________________________________________________________________________
325314

315+
326316
@bot.event
327317
async def on_message(message: discord.Message):
328318
# Nos ID pour pouvoir etre les seuls à pouvoir lancer la commande
@@ -343,18 +333,20 @@ async def on_message(message: discord.Message):
343333
asyncio.sleep(5)
344334
pass
345335
await message.delete()
346-
336+
347337
# _______________________________________________________________________________________________________________________________
348338

339+
349340
@tree.command(name="presentation", description="Laisse moi me présenter et aide moi à trouver mon nom !")
350341
async def presentation(interaction: discord.Interaction):
351342
await interaction.response.defer(ephemeral=True)
352343
await interaction.followup.send(f"{interaction.user.mention}, va voir tes MP !", ephemeral=False)
353344
await presentation_bot(interaction)
354345
logger.info(f"{interaction.user} a demandé la présentation du BOT")
355-
346+
356347
# _______________________________________________________________________________________________________________________________
357348

349+
358350
@tree.command(name="rules", description="Affiche le règlement d'usage du BOT")
359351
async def reglement(interaction: discord.Interaction):
360352
await interaction.response.defer(ephemeral=True)

app/tools.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,37 @@ def ensure_file_exists(path):
1717
async def help(interaction: discord.Interaction):
1818
embed = discord.Embed(
1919
title="📜 Help - Liste des commandes",
20-
description=f"Salut {interaction.user.mention} ! Voici les commandes que tu peux utiliser :",
20+
description=f"Salut {interaction.user.mention} ! Voici les commandes disponibles :",
2121
color=EMBED_COLOR_RED
2222
)
2323

24-
embed.add_field(name="/ping", value="Répond avec Pong ! 🏓", inline=False)
25-
embed.add_field(name="/say", value="Répète ton message 💬", inline=False)
26-
embed.add_field(name="/salut", value="Salue quelqu’un 👋", inline=False)
27-
embed.add_field(
28-
name="/clear", value="Supprime des messages (admin uniquement) 🧹", inline=False)
29-
embed.add_field(name="/pronos_qualifs",
30-
value="Enregistre ton pronostique pour les qualifications", inline=False)
31-
embed.add_field(name="/pronos_course",
32-
value="Enregistre ton pronostique pour les qualifications", inline=False)
33-
embed.add_field(name="/visualisation_pronos_course",
34-
value="Te montre ton pronostique actuel de course", inline=False)
35-
embed.add_field(name="/visualisation_pronos_qualif",
36-
value="Te montre ton pronostique actuel de qualif", inline=False)
37-
embed.add_field(name="/modify_course",
38-
value="Modifie ton pronostique pour la course", inline=False)
39-
embed.add_field(name="/modify_qualif",
40-
value="Modifie ton pronostique pour la qualif", inline=False)
24+
# Commandes utilisateurs
25+
embed.add_field(name="/help", value="📖 Affiche cette liste d’aide", inline=False)
26+
embed.add_field(name="/pronos_course", value="🏁 Enregistre ou modifie ton pronostic pour la **course**", inline=False)
27+
embed.add_field(name="/pronos_qualif", value="⏱️ Enregistre ou modifie ton pronostic pour les **qualifications**", inline=False)
28+
embed.add_field(name="/visualisation", value="🔍 Affiche tes pronos actuels", inline=False)
29+
embed.add_field(name="/leaderboard", value="🏆 Affiche le classement général", inline=False)
30+
embed.add_field(name="/presentation", value="🤖 Laisse le bot se présenter et choisis-lui un nom", inline=False)
31+
embed.add_field(name="/rules", value="📏 Affiche le règlement d’utilisation du bot", inline=False)
32+
33+
# Commandes admin
34+
embed.add_field(name="/clear", value="🧹 Supprime un nombre de messages (admin uniquement)", inline=False)
35+
embed.add_field(name="/admin_ban", value="🔨 Bannir un membre avec raison et article (admin)", inline=False)
36+
embed.add_field(name="/admin_open", value="🟢 Ouvre une session de pronos pour une durée définie (admin)", inline=False)
37+
embed.add_field(name="/admin_close", value="🔴 Ferme la session de pronos en cours (admin)", inline=False)
38+
embed.add_field(name="/admin_status", value="📊 Affiche le mode actuel du bot : manuel ou auto (admin)", inline=False)
39+
embed.add_field(name="/admin_getresult", value="🔄 Met à jour les résultats via l’API (admin)", inline=False)
40+
embed.add_field(name="/admin_stop", value="⛔ Stoppe le mode automatique du bot (admin)", inline=False)
41+
embed.add_field(name="/admin_launch", value="🚀 Lance le mode automatique du bot (admin)", inline=False)
42+
embed.add_field(name="/session", value="🗂️ Configure manuellement une session + update leaderboard (admin)", inline=False)
4143

42-
embed.set_footer(text=EMBED_FOOTER_TEXT, icon_url=EMBED_THUMBNAIL)
4344
embed.set_thumbnail(url=interaction.user.display_avatar.url)
45+
embed.set_footer(text=EMBED_FOOTER_TEXT, icon_url=EMBED_THUMBNAIL)
4446
embed.set_image(url=EMBED_IMAGE)
4547

4648
await interaction.response.send_message(embed=embed, ephemeral=True)
4749

48-
logger.info(
49-
f"{interaction.user.name} à demander help dans le salon {interaction.channel.name}")
50+
logger.info(f"{interaction.user.name} a demandé /help dans {interaction.channel.name}")
5051

5152

5253
async def clear_slash(interaction: discord.Interaction, nombre: int):

docs/source/commands.rst

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,21 @@ General Commands
66

77
.. code:: slash
88
9-
/ping
10-
11-
Replies with "🏓 Pong!". Used to check if the bot is online.
12-
13-
.. code:: slash
14-
15-
/say message: str
9+
/help
1610
17-
Repeats the provided message. Very useful to make the bot speak.
11+
Displays the list of all available commands with explanations.
1812

1913
.. code:: slash
2014
21-
/salut
15+
/presentation
2216
23-
Sends a personalized greeting to the user.
17+
Introduces the bot and lets users suggest a name in DM. These suggestions are saved in a file.
2418

2519
.. code:: slash
2620
27-
/help
21+
/rules
2822
29-
Displays the list of available commands with a brief explanation.
23+
Displays the bot usage rules.
3024

3125
Prediction Commands
3226
-------------------
@@ -35,79 +29,82 @@ Prediction Commands
3529
3630
/pronos_course premier: str deuxieme: str troisieme: str best_lap: str
3731
38-
Allows a user to register their predictions for an event. Can be modified only once.
32+
Submit or update your race predictions. Can be modified only once and only when a session is open.
33+
34+
.. code:: slash
35+
36+
/pronos_qualif premier: str deuxieme: str troisieme: str
37+
38+
Submit or update your qualifying predictions. Can be modified only once and only when a session is open.
3939

4040
.. code:: slash
4141
4242
/visualisation
4343
44-
Displays the user’s previously recorded predictions.
44+
Displays your current predictions (both race and qualifying if available).
4545

4646
.. code:: slash
4747
4848
/leaderboard
4949
50-
Shows the general leaderboard of users based on their prediction scores.
50+
Displays the general leaderboard based on prediction accuracy.
5151

52-
Administration Commands
53-
-----------------------
52+
Admin Commands
53+
--------------
5454

5555
.. code:: slash
5656
5757
/clear nombre: int
5858
59-
Deletes a given number of messages in a channel (admins only).
59+
Deletes a specified number of messages in a channel. Admin only.
6060

6161
.. code:: slash
6262
6363
/admin_ban member: @member reason: str article: str
6464
65-
Bans a member from the server for a specified reason and article (moderators only).
65+
Bans a member for a specified reason and rule/article. Admin only.
6666

6767
.. code:: slash
6868
6969
/admin_open duration: float
7070
71-
Opens a prediction session for a set duration (in hours). Works only in manual mode.
71+
Opens a prediction session manually for a specified duration (in hours). Manual mode only.
7272

7373
.. code:: slash
7474
7575
/admin_close
7676
77-
Closes the prediction session manually.
77+
Closes the current prediction session manually. Manual mode only.
7878

7979
.. code:: slash
8080
8181
/admin_status
8282
83-
Shows the current bot mode (auto or manual).
83+
Returns the current bot mode (manual or auto).
8484

8585
.. code:: slash
8686
8787
/admin_stop
8888
89-
Disables automatic mode and switches back to manual.
89+
Stops automatic mode and reverts to manual mode. Admin only.
9090

9191
.. code:: slash
9292
9393
/admin_launch
9494
95-
Starts automatic mode: the bot automatically opens prediction sessions based on the F1 calendar.
95+
Launches the bot in automatic mode: sessions will be opened and closed based on the F1 calendar.
9696

9797
.. code:: slash
9898
99-
/session saison: int location: str type: str
100-
101-
Manually configures a session (Q for qualifying, R for race). Updates the leaderboard.
99+
/admin_getresult
102100
103-
Special Commands
104-
----------------
101+
Manually fetches session results from the FastF1 API and updates the leaderboard.
105102

106103
.. code:: slash
107104
108-
/presentation
105+
/session saison: int location: str type: str
109106
110-
Introduces the bot and allows users to propose a name via private message. These proposals are saved in a file.
107+
Manually configures a prediction session and updates the leaderboard (Q = qualifying, R = race).
111108

112109
System Commands (non-slash)
113110
---------------------------
@@ -116,11 +113,12 @@ System Commands (non-slash)
116113
117114
!sync
118115
119-
Command available only to administrators listed in `owners_id`. Synchronizes all slash commands with Discord.
116+
Command reserved to the developers (listed in `owners_id`). Syncs all slash commands with Discord.
120117

121118
Notes
122119
-----
123120

124-
- Administration commands require the corresponding permissions (ban, admin, etc.).
125-
- The prediction system uses both manual and automatic modes.
126-
- All logs and errors are properly handled within `try/except` blocks.
121+
- Admin commands require appropriate permissions (administrator, ban members, etc.).
122+
- The prediction system works in both **manual** and **automatic** mode.
123+
- All sessions are time-limited and controlled based on mode.
124+
- Errors are handled using proper `try/except` blocks, and logs are generated accordingly.

0 commit comments

Comments
 (0)