Correction boutons par utilisateur⋅rice

This commit is contained in:
Emmy D'Anello 2025-03-12 00:08:16 +01:00
parent f66e5b5198
commit dfac15796e
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

10
bot.py
View File

@ -258,17 +258,17 @@ async def remiser(ctx: commands.Context, type_defi: Literal['capture', 'competit
class MainView(discord.ui.View):
def __init__(self, ctx: commands.Context, defis: list[dict], timeout: float | None = 180.0):
def __init__(self, ctx: commands.Context, user_id: int, defis: list[dict], timeout: float | None = 180.0):
super().__init__(timeout=timeout)
async def terminer_defi(self, id_defi: int, interaction: discord.Interaction):
async def terminer_defi(self, id_defi: int, user_id: int, interaction: discord.Interaction):
await interaction.response.defer()
await terminer(ctx, id_defi)
await terminer(ctx, id_defi, user_id)
for id_defi in defis:
defi = next(defi for defi in DEFIS['capture'] if defi['id'] == id_defi)
button = discord.ui.Button(style=discord.ButtonStyle.success, label=f"Terminer {defi['nom']}")
button.callback = partial(terminer_defi, self, id_defi)
button.callback = partial(terminer_defi, self, id_defi, user_id)
self.add_item(button)
@ -294,7 +294,7 @@ async def afficher_main(ctx: commands.Context, mode: Literal['public', 'prive']
await ctx.send(f"Défis de l'équipe **{couleur}** :", embeds=embeds)
else:
channel_dm = await bot.create_dm(namedtuple('User', 'id')(author_id))
await channel_dm.send("Vos défis en main :", embeds=embeds, view=MainView(ctx, main))
await channel_dm.send("Vos défis en main :", embeds=embeds, view=MainView(ctx, author_id, main))
@bot.command()