diff --git a/bot.py b/bot.py index baaaec1..da3b7b0 100755 --- a/bot.py +++ b/bot.py @@ -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()