question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Improper token has been passed.

See original GitHub issue

Summary

When having discord.py and discord.py-self installed on the same system, I can not run/host a discord bot(s) while having both installed at the same time. I have pip3 installed discord.py 1.7.3 and discord.py-self 1.9.1 onto the same system. I wanted to run a discord bot instead of a selfbot or run discord bot code along side discord bot code and I get an Improper token has been passed error for the discord bot code. not the selfbot code

Reproduction Steps

How did you make it happen?
  1. python3 -m pip install -U discord.py
  2. python3 -m pip install -U discord.py-self
  3. Make a discord bot how you’d normally make a discord bot.
  4. Set up discord bot code then get the discord bot’s token and pass it in somehow or put client.run(“TOKEN_HERE”) at the bottom of the code file.
  5. Run the file

Code

Relevant code that shows the bug.
# Nothing to show here as the code for the bot itself works just fine.

Traceback Error

Trackback error block for debugging.

(When running discord bot code. not selfbot code)

Traceback (most recent call last):
  File "/home/ori/.local/lib/python3.9/site-packages/discord/http.py", line 349, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "/home/ori/.local/lib/python3.9/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 "/home/ori/Desktop/Projects/ChatterEye/eye_BOT.py", line 73, in <module>
    client.run('BOT_TOKEN_HERE')
  File "/home/ori/.local/lib/python3.9/site-packages/discord/client.py", line 631, in run
    return future.result()
  File "/home/ori/.local/lib/python3.9/site-packages/discord/client.py", line 610, in runner
    await self.start(*args, **kwargs)
  File "/home/ori/.local/lib/python3.9/site-packages/discord/client.py", line 573, in start
    await self.login(*args)
  File "/home/ori/.local/lib/python3.9/site-packages/discord/client.py", line 424, in login
    await self.http.static_login(token.strip())
  File "/home/ori/.local/lib/python3.9/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.

Expected Results

What is supposed to happen?

The discord bot will come online and run its code.

Actual Results

What is currently happening?

Errors and says improper token has been passed.

System Info

Run python -m discord --version and paste the information below.
- Python v3.9.6-final
- discord.py v1.7.3-final
- aiohttp v3.6.2
- system info: Linux 5.10.59-1-MANJARO #1 SMP PREEMPT Sun Aug 15 13:11:32 UTC 2021

Checklist

Let’s make sure this issue is valid!
  • I am using the latest released version of the library.
  • [] I am using a user token. (For this bug, no. This bug involves normal discord bot tokens and not being compatible with discord.py installed at the same time you have discord.py-self installed.)
  • I have shown the entire traceback and exception information.
  • I’ve removed my token from any code.

Additional Information

Put any extra context, weird configurations, or other important info here.

Having discord.py and discord.py-self installed on the same computer at the same time will conflict with each other and means you can not and will not be able to run normal discord bots from your computer/laptop. It is the same thing that happens when trying to run the selfbot code without discord.py-self. It will say improper token. IF I uninstall discord.py-self, I will be able to run discord bot code again and not get this error. But then my selfbot code will give me this error and for obvious reasons, won’t be able to run the selfbot code.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
therealOricommented, Aug 19, 2021

@dolfies

The version you just installed has a renamed import so it doesn’t conflict.

Do import selfcord as discord instead of import discord

Ok. It works now!, Ty for the help!.

1reaction
dolfiescommented, Aug 19, 2021

I just updated that branch with the latest changes. Hopefully it still works.

https://github.com/dolfies/discord.py-self/tree/renamed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improper token passed - python - Stack Overflow
LoginFailure : Improper token has been passed. Before anyone asks, yes I have put in the bot token, not the id or secret....
Read more >
discord.py-self Improper token has been passed. - Reddit
I have been using discord.py-self for quite a while now, but after some time, it started showing me this error: discord.errors.LoginFailure: ...
Read more >
improper token passed · Issue #30 · dolfies/discord.py-self
1]: discord.errors.LoginFailure: Improper token has been passed. Token must be exclusively from a user account, BOT tokens are not supported.
Read more >
Trying to follow discord bot tutorial - The freeCodeCamp Forum
LoginFailure : Improper token has been passed." This is your error here. The token you passed is showing invalid.
Read more >
wrong token! - Replit
I dont think its the wrong token because i have gone in and regenerated the token and re-pasted it and it still give...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found