Ajout d'une commande de debug pour afficher l'état de la mémoire
This commit is contained in:
parent
b096248145
commit
273dc88daa
30
bot.py
30
bot.py
@ -210,25 +210,16 @@ async def tirage(ctx: commands.Context, nb_defis: int = 7):
|
|||||||
data['defis']['mains'][equipe].append(defi['id'])
|
data['defis']['mains'][equipe].append(defi['id'])
|
||||||
data['defis']['tires_capture'].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]:
|
for member_id in data['equipes'][equipe]:
|
||||||
channel_dm = await bot.create_dm(namedtuple("User", "id")(member_id))
|
await main(ctx, author_id=member_id)
|
||||||
await channel_dm.send("Vos défis en main :", embeds=embeds)
|
|
||||||
with DATA_FILE.open('w') as data_file:
|
with DATA_FILE.open('w') as data_file:
|
||||||
json.dump(data, data_file, indent=2)
|
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.")
|
await ctx.send("Les mains de départ ont bien été tirées ! Le contenu vous a été envoyé en MP.")
|
||||||
|
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def main(ctx: commands.Context):
|
async def main(ctx: commands.Context, *, author_id: int | None = None):
|
||||||
author_id = ctx.author.id
|
author_id = author_id or ctx.author.id
|
||||||
for couleur, membres_equipe in data['equipes'].items():
|
for couleur, membres_equipe in data['equipes'].items():
|
||||||
if author_id in membres_equipe:
|
if author_id in membres_equipe:
|
||||||
break
|
break
|
||||||
@ -247,8 +238,21 @@ async def main(ctx: commands.Context):
|
|||||||
await channel_dm.send("Vos défis en main :", embeds=embeds)
|
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
|
@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))
|
await ctx.send(str(error))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user