【发布时间】:2020-05-13 04:56:18
【问题描述】:
我一直在使用 discord.py 制作机器人,但遇到了问题。我正在运行一个机器人,我决定再做一个。当我在新服务器上对其进行测试时,我收到一条错误消息,上面写着RuntimeError: Event loop is closed.,但另一个机器人没有发生这种情况,它的代码与第一个机器人完全相同,只是使用了不同的令牌。为什么会发生这种情况,我应该怎么做才能解决它?这是完整的错误信息:
Traceback (most recent call last):
File "C:\Python38\lib\site-packages\discord\http.py", line 261, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "C:\Python38\lib\site-packages\discord\http.py", line 225, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\26afa\Documents\GameBotDiscord\GameBot3000.py", line 24, in <module>
client.run(token) # recall my token was saved!
File "C:\Python38\lib\site-packages\discord\client.py", line 640, in run
return future.result()
File "C:\Python38\lib\site-packages\discord\client.py", line 621, in runner
await self.start(*args, **kwargs)
File "C:\Python38\lib\site-packages\discord\client.py", line 584, in start
await self.login(*args, bot=bot)
File "C:\Python38\lib\site-packages\discord\client.py", line 442, in login
await self.http.static_login(token.strip(), bot=bot)
File "C:\Python38\lib\site-packages\discord\http.py", line 265, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000019F1121F430>
Traceback (most recent call last):
File "C:\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Python38\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "C:\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
【问题讨论】:
-
有没有具体指向的线?也许完整的错误回溯会有所帮助。机器人是否完全启动?还是运行某个命令时出错?
-
根本不启动;当我运行代码时,它会立即给我错误消息。
-
是否可以在答案中包含错误回溯?它可能指向导致此问题的行
-
好的,我添加了错误信息。
标签: python bots discord.py