Compare commits

..

No commits in common. "9eb13560f236ec114f8e481c9b67a7024eac71d8" and "3cd8bf82dc7dbb7d5545991007a72b008df2e1ad" have entirely different histories.

41
bot.py
View File

@ -2,7 +2,6 @@
from collections import namedtuple
import copy
from datetime import datetime, timedelta
from functools import partial
import json
from pathlib import Path
@ -230,33 +229,6 @@ 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
@ -383,16 +355,9 @@ async def melanger(ctx: commands.Context, nb_defis: int = 5):
await afficher_main(ctx, author_id=member_id)
@bot.command()
async def de(ctx: commands.Context, nb_faces: int = 6):
resultat = random.randint(1, nb_faces + 1)
await ctx.reply(f":game_die: Résultat du dé à {nb_faces} faces : **{resultat}**")
@bot.command()
async def chronometre(ctx: commands.Context, minutes: int = 30, secondes: int = 0):
fin = datetime.now() + timedelta(minutes=minutes, seconds=secondes)
await ctx.send(f"Chronomètre lancé pour **{minutes:02d}:{secondes:02d}** (fin à <t:{int(fin.timestamp())}:T>)\nFin <t:{int(fin.timestamp())}:R>")
await ctx.reply(f":dice: Résultat du dé à {nb_faces} faces : **{resultat}**")
@bot.command()
@ -439,14 +404,10 @@ async def save(ctx: commands.Context):
@defis.error
@description.error
@tirage.error
@competition.error
@remiser.error
@afficher_main.error
@terminer.error
@echange.error
@melanger.error
@de.error
@chronometre.error
@debug.error
@reload.error
@save.error