所以我在 Spyder 上试图连接我的不和谐机器人,我正在运行这段代码:
import discord
import nest_asyncio
nest_asyncio.apply()
client = discord.Client()
@client.event
async def on_ready():
print('The bot is ready')
@client.event
async def on_message(message):
if message.content.lower()=='ping':
await message.channel.send('pong')
client.run(token)
我正面临这个错误:
Exception in callback <TaskStepMethWrapper object at 0x000002A55BF8DF40>() handle: <Handle <TaskStepMethWrapper object at 0x000002A55BF8DF40>()>
Traceback (most recent call last):
File "C:\Users\33767\anaconda3\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
RuntimeError: Cannot enter into task <ClientEventTask state=pending event=on_ready coro <function on_ready at 0x000002A55BEECE50>> while another task <Task pending name='Task-2' coro=<Kernel.dispatch_queue() running at C:\Users\33767\anaconda3\lib\site-packages\ipykernel\kernelbase.py:457> cb=[IOLoop.add_future.<locals>.<lambda>() at C:\Users\33767\anaconda3\lib\site-packages\tornado\ioloop.py:688]> is being executed.
似乎某些任务之间存在冲突,你们知道如何解决这个问题吗?