我正在搜索编写一个shutdownroom命令,使特定房间中的所有用户静音。 因此,我必须获得编写消息的用户和消息内容
现在我有这个,但在这种情况下,每条消息都会被监控:
def shut_check(msg):
return msg.content
@client.command()
@commands.has_permissions(manage_messages=True)
async def shut_room(ctx):
await ctx.send("Please send me the id of the room that you want to shut down.")
content = await client.wait_for("message", check=check)
现在,我有了发送的消息的内容,但是如何验证消息的作者是否是ctx.author?
我有另一个要求,你能解释一下pass_context=True
的目的是什么吗
@client.command(pass_context=True)
这是一个简单的逻辑,在命令中定义
check
函数。此外,您当前的检查没有任何意义,它将始终返回一个与true相似的值另外,在等待消息时,它不会返回内容本身,而是返回一个
discord.Message
实例,我认为您对check函数感到困惑解释
check
参数:bot将等待所需的事件,直到check
函数返回truthy值编辑:
在命令外部定义check func
我已经用另一个函数包装了check函数,以便可以传递
Context
参数相关问题 更多 >
编程相关推荐