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

EVENT LOOP is closed discord.py, possible token error

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

I have looked at the other posts about this issue and didnt find any working solutions. My bot is currently undergoing a development overhaul and I'm moving a lot of my stored data (mod mail bot) into a aiosqlite db. In doing so I have come across this issue.

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

to prevent leaking my token I import another python file from Token import token which its sole purpose is to run this line of code return "token here" (full code here)

any clue as to what's going on? has my token been deauthorized or something? (I tried remaking my token and it works for a short time)

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

My code was completely correct my token was however invalidated by discord and redoing my token fixed it