1

This is the huge error im getting:

Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Python\Python310\site-packages\discord\http.py", line 349, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "C:\Users\User\AppData\Roaming\Python\Python310\site-packages\discord\http.py", line 302, 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 "f:\Programming\Python\Discord bot\LastOneEverythingCombined\TEST.py", line 112, in <module>
    client.run('OTA0NjMxMzE2MzU0NTg4NzEz.YX-VkQ._B-EnQRE3IhWYl0psJA8UxZuI6s')
  File "C:\Users\User\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 631, in run
    return future.result()
  File "C:\Users\User\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 610, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\User\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 573, in start
    await self.login(*args)
  File "C:\Users\User\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 424, in login
    await self.http.static_login(token.strip())
  File "C:\Users\User\AppData\Roaming\Python\Python310\site-packages\discord\http.py", line 353, 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 0x000001B4F30E1EA0>
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
    self._check_closed()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001B4F30E1EA0>
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
    self._check_closed()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001B4F30E1EA0>
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
    self._check_closed()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

I have no clue how to fix it and have tried everything on the web This is my code: in the spot of Token i have my token but ofcourse lets keep it hidden :)

client = commands.Bot(command_prefix='.')
Code....
client.run('Token')

Last time i put my entire code there and people got mad so i am now just putting the code i think might be necessary for this problem, if you need any other bits of code just reply with i need all the code to solve this error or more code and then the specific bit that you need or think might be in it

6
  • 2
    As the error suggests, discord.errors.LoginFailure: Improper token has been passed. your token is incorrect.. Commented Jan 10, 2022 at 20:14
  • Regenerate a token in the Discord Application Portal and copy that token into client.run('Token') Commented Jan 11, 2022 at 1:12
  • I copied and pasted the token and regenerated it 2 times allready.
    – Sdej Sdeyt
    Commented Jan 11, 2022 at 16:50
  • And its happening with all of my other bots aswel that worked before.
    – Sdej Sdeyt
    Commented Jan 11, 2022 at 16:54
  • And its happening with all the different scripts aswel who had no problem with it at first and havent been edited for month exept for the Token ofcourse cause needed to update it. And it has nothing to do with visual studio code cause its happening aswel in a normal python terminal.
    – Sdej Sdeyt
    Commented Jan 11, 2022 at 16:56

2 Answers 2

0

i just hit my head on my keyboard for a bit over this but i think i found the answer; print(Token) and see what it spits out. maybe you've included a pair of apostrophes or braces that shouldn't be in your token string

0

I had the same problem and i fix it by writting [1:-1] after the token: TOKEN = os.getenv('DISCORD_TOKEN')[1:-1]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.