import discord
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio
bot = commands.Bot(commabds_prefix='#')
@bot_event
async def on_ready():
print ("Ready when you are")
print ("I am running on" + bot.user.name)
print ("With the ID: " + bot.user.id)
bot.run("Token")
我正在使用Python创建一个不和谐的bot,当我使用此代码时,我会通过命令提示符得到此错误:
Traceback (most recent call last):
File "C:\Users\reals\Desktop\Discord Bot\bot.py", line 3, in <module>
import discord
File "C:\Users\reals\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\reals\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 38, in <module>
from .state import ConnectionState
File "C:\Users\reals\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\state.py", line 36, in <module>
from . import utils, compat
File "C:\Users\reals\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\compat.py", line 32
create_task = asyncio.async
^
SyntaxError: invalid syntax
答案 0 :(得分:0)
由于您已经从 discord.ext 导入命令,因此就我所见,您不需要导入 Bot。因为你没有使用它。
除此之外,您的 bot = commands.Bot(commabds_prefix='#')
输入错误。
它是commands_prefix
,而不是commabds
,所以改变它,你应该可以去。
答案 1 :(得分:-1)
好像是第3行的import语句引起了问题,也是不需要的。
您可以删除第3行并重试吗?
请注意,您正在使用 command.Bot(), command 从第2行导入。