Défis de compétition et remisage

This commit is contained in:
Emmy D'Anello 2025-03-11 22:04:03 +01:00
parent 3cd8bf82dc
commit a3c71800af
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

29
bot.py
View File

@ -229,6 +229,33 @@ async def tirage(ctx: commands.Context, nb_defis: int = 5):
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 competition(ctx: commands.Context):
defi_competition = random.choice([defi for defi in DEFIS['competition'] if defi['id'] not in data['defis']['tires_competition']])
data['defis']['tires_competition'].append(defi_competition['id'])
embed = discord.Embed(title=defi_competition['nom'], description=defi_competition['description'])
embed.set_footer(text=f"Défi de compétition n°{defi_competition['id']}")
with DATA_FILE.open('w') as data_file:
json.dump(data, data_file, indent=2)
await ctx.send("@everyone Un canton est attaqué ! L'équipe vainqueure de ce défi conservera son contrôle jusqu'à la fin du jeu :", embed=embed)
@bot.command()
async def remiser(ctx: commands.Context, type_defi: Literal['capture', 'competition'] = "capture", id_defi: int | None = None):
defis = DEFIS[type_defi]
try:
defi = next(defi for defi in defis if defi['id'] == id_defi)
except StopIteration:
raise commands.BadArgument(f"Le défi de {type_defi}{id_defi} n'existe pas.")
if id_defi in data['defis'][f'tires_{type_defi}']:
data['defis'][f'tires_{type_defi}'].remove(id_defi)
with DATA_FILE.open('w') as data_file:
json.dump(data, data_file, indent=2)
await ctx.reply(f"Le défi de {type_defi}{id_defi} ({defi['nom']}) a été retiré de la défausse et pourra à nouveau être tiré au sort.")
else:
await ctx.reply(f"Le défi de {type_defi}{id_defi} ({defi['nom']}) n'était déjà pas dans la défausse.")
@bot.command(name="main")
async def afficher_main(ctx: commands.Context, mode: Literal['public', 'prive'] = "prive", author_id: int | None = None):
author_id = author_id or ctx.author.id
@ -404,6 +431,8 @@ async def save(ctx: commands.Context):
@defis.error
@description.error
@tirage.error
@competition.error
@remiser.error
@afficher_main.error
@terminer.error
@echange.error