当我尝试编写一个简单的机器人以在调用“!cookie”上发送cookie表情符号时,收到此错误消息。
RESTART: C:/Users/matth/AppData/Local/Programs/Python/Python37-32/InfoBot.py
Traceback (most recent call last):
File "C:/Users/matth/AppData/Local/Programs/Python/Python37-32/InfoBot.py", line 1, in <module>
import discord
File "C:\Users\matth\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "C:\Users\matth\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 38, in <module>
from .state import ConnectionState
File "C:\Users\matth\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\state.py", line 36, in <module>
from . import utils, compat
File "C:\Users\matth\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\compat.py", line 32
create_task = asyncio.async
^
SyntaxError: invalid syntax
这是我的代码。
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time
Client = discord.Client()
client = commands.Bot(command_prefix = "!")
@client.event
async def on_ready():
print("Bot is ready!")
@client.event
async def on_message(message):
if message.content == "cookie":
await client.send_message(message.channel, ":cookie:")
client.run("********************************")
我正在审查我的令牌,但我希望这不会干扰解决问题。谢谢<3
答案 0 :(得分:2)
您的库副本缺少此提交:
问题是Python 3.7引入了async
作为关键字,因此asyncio.async
不再是有效的语法。