Ajout d'une commande de debug pour afficher l'état de la mémoire

This commit is contained in:
Emmy D'Anello 2025-03-11 18:13:30 +01:00
parent b096248145
commit 273dc88daa
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

30
bot.py
View File

@ -210,25 +210,16 @@ async def tirage(ctx: commands.Context, nb_defis: int = 7):
data['defis']['mains'][equipe].append(defi['id'])
data['defis']['tires_capture'].append(defi['id'])
main = data['defis']['mains'][equipe]
embeds = []
colour = discord.Color.red() if equipe == "rouge" else discord.Color.green()
for id_defi in main:
defi = next(defi for defi in DEFIS['capture'] if defi['id'] == id_defi)
embed = discord.Embed(title=defi['nom'], description=defi['description'], colour=colour)
embed.set_footer(text=f"Défi n°{defi['id']}")
embeds.append(embed)
for member_id in data['equipes'][equipe]:
channel_dm = await bot.create_dm(namedtuple("User", "id")(member_id))
await channel_dm.send("Vos défis en main :", embeds=embeds)
await main(ctx, author_id=member_id)
with DATA_FILE.open('w') as data_file:
json.dump(data, data_file, indent=2)
await ctx.send("Les mains de départ ont bien été tirées ! Le contenu vous a été envoyé en MP.")
@bot.command()
async def main(ctx: commands.Context):
author_id = ctx.author.id
async def main(ctx: commands.Context, *, author_id: int | None = None):
author_id = author_id or ctx.author.id
for couleur, membres_equipe in data['equipes'].items():
if author_id in membres_equipe:
break
@ -247,8 +238,21 @@ async def main(ctx: commands.Context):
await channel_dm.send("Vos défis en main :", embeds=embeds)
@bot.command()
async def debug(ctx: commands.Context, key: Literal['equipes', 'cantons', 'defis']):
data_json = json.dumps(data[key], indent=4)
await ctx.send(f"```json\n{data_json}\n```")
@carte.error
@reset.error
@equipe.error
async def equipe_error(ctx, error):
@defis.error
@description.error
@tirage.error
@main.error
@debug.error
async def on_error(ctx, error):
await ctx.send(str(error))