我是编程新手。我正在尝试让我的Discord机器人打开命令提示符来确认它可以运行,但我遇到了这个错误:
File "C:\Users\---\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\---\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\---\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "C:\Users\---\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
[Finished in 0.871s]
代码:
import discord
from discord.ext import commands
client=commands.Bot(command_prefix = '.')
@client.event
async def on_ready():
print('ok')
client.run(token)
是什么导致了这个错误,我该如何修复它?
编辑:经过一些测试,我相信 "client.run(token)" 是导致 "event loop is closed" 的原因,不确定为什么。