Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当';等待&x27;在客户端前面。发送\u消息_Python_Async Await_Discord.py - Fatal编程技术网

Python 当';等待&x27;在客户端前面。发送\u消息

Python 当';等待&x27;在客户端前面。发送\u消息,python,async-await,discord.py,Python,Async Await,Discord.py,我正在使用discord.py版本0.16.8。我的客户端也是:client=discord.client() 当我准备写wait client.send_message(所有常用代码都在这里)wait时,我收到一个错误,上面写着: “类“Message”未定义“await”,因此不能在其实例上使用“await”运算符” 当我尝试在Discord中运行我的机器人并尝试我的一个命令时,它不工作,并且没有消息弹出。这是我的命令代码: @client.event async def on_messag

我正在使用discord.py版本0.16.8。我的客户端也是:
client=discord.client()

当我准备写
wait client.send_message(所有常用代码都在这里)
wait时,我收到一个错误,上面写着:
“类“Message”未定义“await”,因此不能在其实例上使用“await”运算符”

当我尝试在Discord中运行我的机器人并尝试我的一个命令时,它不工作,并且没有消息弹出。这是我的命令代码:

@client.event
async def on_message(message):

    if message.content == '..roll':
    await client.send_message(message.channel, str(randint(1, 6)))

非常感谢您的帮助,谢谢

看起来您在
if
语句中忘记了缩进

@client.event
async def on_message(message):

    if message.content == '..roll':
        await client.send_message(message.channel, str(randint(1, 6)))