discord.py - 如何发出验证禁令命令?
问题描述
是的,我想这样做,所以当我执行“/ban @user reason”时,机器人会回复一个嵌入内容,说你确定要禁止这个用户并用勾号对其消息做出反应,并等待反应制定禁令的人。
解决方案
尝试这个:
@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)
推荐阅读
- ssms-2014 - 更新员工工资记录
- tags - 我如何才能在团队城市中运行并非所有机器人测试用例,而只运行具有 [tags] = A 和/或 [tags]=B 的那些
- java - 绝对 uri: [http://java.sun.com/jsp/jstl/core] 无法解析错误
- java - 在哪里可以找到 java 中预定义方法/类的源代码?
- java - 使用 JPA 将包括关系在内的整个表加载到内存中
- php - phpMyAdmin 参数错误
- javascript - 如何在Angular的异步管道中合并数据
- javascript - P5 SVG 图像模式
- python-3.x - 如何以非序列顺序将矩阵替换为另一个矩阵
- database - 用户在数据库中的位置