Trying to follow discord bot tutorial

I should be doing everything correctly, but it comes up with a stupidly long error message. I just started learning coding, so I have no idea what’s going on.

"Traceback (most recent call last):
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py”, line 293, in static_login
data = await self.request(Route(‘GET’, ‘/users/@me’))
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py”, line 247, 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 “main.py”, line 18, in
client.run(os.getenv(‘TOKEN’))
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py”, line 718, in run
return future.result()
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py”, line 697, in runner
await self.start(*args, **kwargs)
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py”, line 660, in start
await self.login(*args, bot=bot)
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py”, line 509, in login
await self.http.static_login(token.strip(), bot=bot)
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py”, line 297, in static_login
raise LoginFailure(‘Improper token has been passed.’) from exc
discord.errors.LoginFailure: Improper token has been passed."

This is your error here. The token you passed is showing invalid.

I just check and even regenerated the token and it still shows the same error?

What happens if you try to print os.getenv('TOKEN')? Does it display your token?

Note: Please don’t share any screenshots or display your token. I just need a yes or no. :slight_smile:

I don’t think so ? :man_shrugging:

I had the same problem, turns out I was using my discord token instead of the bots token. hope this helps you.

1 Like