首页 > 解决方案 > 如何发出验证禁令命令?

问题描述

是的,我想这样做,所以当我执行“/ban @user reason”时,机器人会回复一个嵌入内容,说你确定要禁止这个用户并用勾号对其消息做出反应,并等待反应制定禁令的人。

标签: discord.py

解决方案


尝试这个:

@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)

推荐阅读