Warm tip: This article is reproduced from serverfault.com, please click

python-EVENT LOOP已关闭discord.py,可能出现令牌错误

(python - EVENT LOOP is closed discord.py, possible token error)

发布于 2020-11-28 00:38:59

我查看了有关此问题的其他帖子,但未找到任何有效的解决方案。我的机器人目前正在进行开发检查,并且我将大量存储的数据(mod邮件机器人)移到了aiosqlite数据库中。在这样做时,我遇到了这个问题。

Traceback (most recent call last):
  File "C:\Users\L0m\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 291, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "C:\Users\L0m\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 245, 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 "d:/Programming/AusSea-Bot/main.py", line 225, in <module>
    client.run(token())
  File "C:\Users\L0m\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 708, in run
    return future.result()
  File "C:\Users\L0m\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 687, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\L0m\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 650, in start
    await self.login(*args, bot=bot)
  File "C:\Users\L0m\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 499, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "C:\Users\L0m\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 295, 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 0x000001D4CC4B75E0>
Traceback (most recent call last):
  File "C:\Users\L0m\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\L0m\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\L0m\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Users\L0m\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

为了防止泄漏我的令牌,我导入了另一个python文件from Token import token,其唯一目的是运行此行代码return "token here"此处完整代码

关于发生了什么的任何线索?我的令牌被取消授权了吗?(我尝试重新制作令牌,并且可以在短时间内使用)

Questioner
IsaacWP121
Viewed
11
IsaacWP121 2020-11-30 14:30:57

我的代码是完全正确的,但是我的令牌却因不和谐而失效,并重做了我的令牌,使它无效