【发布时间】:2021-08-23 10:59:10
【问题描述】:
def test():
await message.author.send('ehy')
@bot.event
async def on_message(message):
if message.author.id == 2980828228298:
test()
我不明白为什么这个简单的功能不起作用。错误是“等待”。有什么帮助吗?
【问题讨论】:
-
请分享完整的错误。
-
我什至无法启动程序,出现语法错误:'await' outside async function
-
await 关键字只允许在标有 async 的函数中使用。
-
你能给我举个例子吗?这是我第一次使用函数。
标签: python function discord discord.py