如何制作验证禁止命令?

时间:2021-04-14 12:43:22

标签: discord.py

是的,我想这样做,当我执行“/ban @user reason”时,机器人会以嵌入的方式响应,说您确定要禁止此用户并通过勾号对它的消息做出反应,并等待做出禁令的人的反应。

1 个答案:

答案 0 :(得分:1)

试试这个:

@bot.command(name="ban")
async def ban(ctx, member, reason=""):
    if not ctx.message.mentions:
        await ctx.channel.send("You must mention a user to use this command")
    embed = discord.Embed(
        title="Confirm ban",
        description=f"Are you sure you want to ban {member.mention}",
        color=0xff0000
    )
    message = await ctx.channel.send(embed=embed)
    await message.add_reaction(u"\U0001F44D")

    def check(pay):
        pay.member == member and pay.message_id == ctx.message.id

    await bot.wait_for("raw_reaction_add", check=check)
    await member.ban(reason=reason)