I’m doing my own discord bot, through a lot of mistakes and errors I came to a big same error, and I have no idea what it is.
File "C:UsersDanielPycharmProjectsdiscord-botvenvlibsite-packagesdiscordhttp.py", line 300, in static_login
data = await self.request(Route('GET', "/users/@me"))
File "C:UsersDanielPycharmProjectsdiscord-botvenvlibsite-packagesdiscordhttp.py", line 254, 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:UsersDanielPycharmProjectsdiscord-botvenvlibsite-packagesdiscordclient.py", line 723, in run
return future.result()
File "C:UsersDanielPycharmProjectsdiscord-botvenvlibsite-packagesdiscordclient.py", line 702, in runner
await self.start(*args, **kwargs)
File "C:UsersDanielPycharmProjectsdiscord-botvenvlibsite-packagesdiscordclient.py", line 665, in start
await self.login(*args, bot=bot)
File "C:UsersDanielPycharmProjectsdiscord-botvenvlibsite-packagesdiscordclient.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "C:UsersDanielPycharmProjectsdiscord-botvenvlibsite-packagesdiscordhttp.py", line 304, 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 0x000001B8A2E9D000>
Traceback (most recent call last):
File "C:UsersDanielAppDataLocalProgramsPythonPython310libasyncioproactor_events.py", line 116, in __del__
self.close()
File "C:UsersDanielAppDataLocalProgramsPythonPython310libasyncioproactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:UsersDanielAppDataLocalProgramsPythonPython310libasynciobase_events.py", line 750, in call_soon
self._check_closed()
File "C:UsersDanielAppDataLocalProgramsPythonPython310libasynciobase_events.py", line 515, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Process finished with exit code 1
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You get a HTTP 401 Statuscode (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401).
That means that the resource you’re trying to access is protected by some kind of authorization. You have to pass a username and password or an authorization token in your request.
I don’t know this discord-bot libary, but I guess that this lib offers some kind of authorization.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0