这是我的查询代码:
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 重写文档的更多信息。
检查功能
然后,该check
函数首先检查发送消息的频道是否为 DM,检查作者是否为会员,检查消息内容是否为mbs accept
.
等待函数
然后,它使用我们提供的检查来等待消息。在此处阅读有关该wait_for
功能的更多信息。
PS:很抱歉回复晚了,如果您有任何不可预见的错误或有疑问,请随时跟进!