Discord.py重写已使bot响应DMs

Discord.py重写已使bot响应DMs,discord.py,discord.py-rewrite,dm,Discord.py,Discord.py Rewrite,Dm,我正在尝试让我的机器人响应接受规则的DM消息 以下是我到目前为止的情况: @bot.event 成员加入时的异步定义(成员): role=discord.utils.get(member.servers.roles,name='Newcomers')#get role 等待bot。添加角色(成员,角色)#将角色交给用户 等待bot.member.send(“欢迎来到版主bot服务器!我需要您先阅读规则,然后在此DM中使用`mbs accept`接受”)#发送消息 #等待接受 以下是我的查询代码:

我正在尝试让我的机器人响应接受规则的DM消息

以下是我到目前为止的情况:

@bot.event
成员加入时的异步定义(成员):
role=discord.utils.get(member.servers.roles,name='Newcomers')#get role
等待bot。添加角色(成员,角色)#将角色交给用户
等待bot.member.send(“欢迎来到版主bot服务器!我需要您先阅读规则,然后在此DM中使用`mbs accept`接受”)#发送消息
#等待接受

以下是我的查询代码:

role = discord.utils.get(member.guild.roles, name='Newcomers') #get role
await member.add_roles(role) #give the role to the user
await member.send("Welcome to the Moderator Bot Server! I will need you to first read the rules then accept by using the `mbs accept` in this DM")#send a message

def check(m):
    return isinstance(m.channel, discord.DMChannel) and m.author == member and m.content == "mbs accept"

await bot.wait_for("message", check=check)
#do stuff here; this line runs once the user types `mbs accept` in the DM (maybe you want to send the user a message that thanks them for accepting the rules?)
前3行是您提供给我们的,不过我对它们进行了更新,使它们适用于discord.py-rewrite(请阅读discord.py rewrite文档的更多内容)

检查功能 然后,
check
函数首先检查发送消息的频道是否为DM,检查作者是否为成员,检查消息内容是否为
mbs accept

等待功能 然后,它使用我们提供的检查来等待消息。请阅读有关
wait\u for
函数的更多信息


PS:很抱歉回复太晚,如果您有任何无法预料的错误或疑问,请随时跟进!

程序有什么问题?您需要什么帮助?猜测一下,这应该是
等待成员。添加角色(角色)
等待成员。发送(…)
这看起来像是重写之前的一些旧discord.py代码。您运行的是什么discord.py版本?如果您运行的是高于1.0.0的版本,请遵循Patrick Haugh的建议。@Holden程序工作正常,我只是想让用户通过输入命令来接受规则。我不知道如何让机器人检测到它DMS中的命令您使用的是哪个discord.py版本?对于新版本,使用
客户端。等待
;对于旧版本,使用
客户端。等待消息