我正在通过重写制作一个不和谐的bot,但是当我的命令运行时,SOMETIMES会立即发送所有消息,有时效果很好。有人知道为什么吗?我为此苦苦挣扎了
@client.event
async def on_message(message):
if message.content.startswith("!order"):
channel = message.channel
await channel.send("in game name")
in_game_name = await client.wait_for('message', check=None)
await channel.send("in game ID")
in_game_ID = await client.wait_for('message', check=None)
await channel.send("cargo type")
cargo_type = await client.wait_for('message', check=None)
await channel.send("cargo limit")
cargo_limit = await client.wait_for('message', check=None)
await channel.send("storage")
storage = await client.wait_for('message', check=None)
await channel.send("priority")
priority = await client.wait_for('message', check=None)
答案 0 :(得分:2)
您可以创建一个检查功能,该功能仅检查邮件是否位于正确的频道中,并且不是由漫游器发送的邮件:
@client.event
async def on_message(message):
def check(m):
return m.channel == message.channel and m.author != client.user
if message.content.startswith("!order"):
channel = message.channel
await channel.send("in game name")
in_game_name = await client.wait_for('message', check=check)
...