Correction boutons par utilisateur⋅rice
This commit is contained in:
parent
f66e5b5198
commit
dfac15796e
10
bot.py
10
bot.py
@ -258,17 +258,17 @@ async def remiser(ctx: commands.Context, type_defi: Literal['capture', 'competit
|
|||||||
|
|
||||||
|
|
||||||
class MainView(discord.ui.View):
|
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)
|
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 interaction.response.defer()
|
||||||
await terminer(ctx, id_defi)
|
await terminer(ctx, id_defi, user_id)
|
||||||
|
|
||||||
for id_defi in defis:
|
for id_defi in defis:
|
||||||
defi = next(defi for defi in DEFIS['capture'] if defi['id'] == id_defi)
|
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 = 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)
|
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)
|
await ctx.send(f"Défis de l'équipe **{couleur}** :", embeds=embeds)
|
||||||
else:
|
else:
|
||||||
channel_dm = await bot.create_dm(namedtuple('User', 'id')(author_id))
|
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()
|
@bot.command()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user