我正在学习如何使用discord.py API和这个示例代码(来自这里。https:/discordpy.readthedocs.ioenlatestquickstart.html)。)不工作。我认为这与async语法有关,但我不知道它可能有什么问题.任何帮助将被感激!
import discord
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
client.run('private token that is filled in in the actual code')
在第7行,"async def on_ready():",错误是async语法无效。我使用的是3.8.3版本
client = commands.Bot(command_prefix = '!')
而不是 client = commands.Client()
你应该导入 commands
太
import discord
from discord.ext import commands