Compare commits
2 Commits
3cd8bf82dc
...
9eb13560f2
Author | SHA1 | Date | |
---|---|---|---|
9eb13560f2 | |||
a3c71800af |
41
bot.py
41
bot.py
@ -2,6 +2,7 @@
|
||||
|
||||
from collections import namedtuple
|
||||
import copy
|
||||
from datetime import datetime, timedelta
|
||||
from functools import partial
|
||||
import json
|
||||
from pathlib import Path
|
||||
@ -229,6 +230,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} n°{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} n°{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} n°{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
|
||||
@ -355,9 +383,16 @@ 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":dice: Résultat du dé à {nb_faces} faces : **{resultat}**")
|
||||
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>")
|
||||
|
||||
|
||||
@bot.command()
|
||||
@ -404,10 +439,14 @@ 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user