dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
720 stars 164 forks source link

[BUG] Improper token has been passed. #79

Closed therealOri closed 3 years ago

therealOri commented 3 years ago

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!

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.

dolfies commented 3 years ago

This has been discussed multiple times.
Some people wanted me to rename, some didn't; now there's a branch that has a renamed import name.

I'm not 100% sure if it's fully up-to-date, though. It might be on v1.9.0.
EDIT: It is on v1.9.0. I'll update it tomorrow.

The proper solution would be to use venvs.

therealOri commented 3 years ago

This has been discussed multiple times. Some people wanted me to rename, some didn't; now there's a branch that has a renamed import name.

I'm not 100% sure if it's fully up-to-date, though. It might be on v1.9.0. EDIT: It is on v1.9.0. I'll update it tomorrow.

The proper solution would be to use venvs.

Ok. When you get to it tomorrow, it'd be great/nice if you or anyone else could send me the link to that branch to use.

therealOri commented 3 years ago

@dolfies I'll just be here then.

dolfies commented 3 years ago

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

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

therealOri commented 3 years ago

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

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

Ok, Ty!

therealOri commented 3 years ago

@dolfies Slight issue. I don't know how to install the renamed version,I tried to use the setup.py file and it bugged out to when I couldn't run selfbot code. "Improper token passed" error. And now I can't uninstall discord.py-self even as root user (for linux).

My file system does not acknowledge that /usr/lib/python3.9/site-packages/discord.py_self-1.9.1-py3.9.egg exists, It doesn't show up when I look for it. Only when trying to uninstall it or when installing it again, it says already exists. But then I get the following error when trying to uninstall.

$ python3 -m pip uninstall discord.py-self
Found existing installation: discord.py-self 1.9.1
Uninstalling discord.py-self-1.9.1:
  Would remove:
    /usr/lib/python3.9/site-packages/discord.py_self-1.9.1-py3.9.egg
Proceed (Y/n)? Y

ERROR: Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.9/shutil.py", line 806, in move
    os.rename(src, real_dst)
OSError: [Errno 18] Invalid cross-device link: '/usr/lib/python3.9/site-packages/discord.py_self-1.9.1-py3.9.egg' -> '/tmp/pip-uninstall-vofimglx'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ori/.local/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 173, in _main
    status = self.run(options, args)
  File "/home/ori/.local/lib/python3.9/site-packages/pip/_internal/commands/uninstall.py", line 93, in run
    uninstall_pathset = req.uninstall(
  File "/home/ori/.local/lib/python3.9/site-packages/pip/_internal/req/req_install.py", line 633, in uninstall
    uninstalled_pathset.remove(auto_confirm, verbose)
  File "/home/ori/.local/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 384, in remove
    moved.stash(path)
  File "/home/ori/.local/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 281, in stash
    renames(path, new_path)
  File "/home/ori/.local/lib/python3.9/site-packages/pip/_internal/utils/misc.py", line 331, in renames
    shutil.move(old, new)
  File "/usr/lib/python3.9/shutil.py", line 824, in move
    rmtree(src)
  File "/usr/lib/python3.9/shutil.py", line 718, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/lib/python3.9/shutil.py", line 655, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/lib/python3.9/shutil.py", line 675, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/usr/lib/python3.9/shutil.py", line 673, in _rmtree_safe_fd
    os.unlink(entry.name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'not-zip-safe'

Running the same command but as root/admin

Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.9/site-packages/pip/__main__.py", line 23, in <module>
    from pip._internal.cli.main import main as _main  # isort:skip # noqa
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/cmdoptions.py", line 25, in <module>
    from pip._internal.cli.progress_bars import BAR_TYPES
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/progress_bars.py", line 12, in <module>
    from pip._internal.utils.logging import get_indentation
  File "/usr/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 18, in <module>
    from pip._internal.utils.misc import ensure_dir
  File "/usr/lib/python3.9/site-packages/pip/_internal/utils/misc.py", line 34, in <module>
    from pip._internal.locations import get_major_minor_version, site_packages, user_site
  File "/usr/lib/python3.9/site-packages/pip/_internal/locations/__init__.py", line 9, in <module>
    from . import _distutils, _sysconfig
  File "/usr/lib/python3.9/site-packages/pip/_internal/locations/_sysconfig.py", line 8, in <module>
    from pip._internal.exceptions import InvalidSchemeCombination, UserInstallationInvalid
ImportError: cannot import name 'InvalidSchemeCombination' from 'pip._internal.exceptions' (/usr/lib/python3.9/site-packages/pip/_internal/exceptions.py)

I think it may have something to do with the _ in the name idk if I have to do something with the setup.py file to uninstall this, or what.. because nothing I am trying to do is helping and I still can't use my selfbot code.

therealOri commented 3 years ago

@dolfies

Update: Re installing setup.py but using the following commands fixed the removing the files issue and am back to where I started.

$ sudo python setup.py install --record files.txt
$ sudo rm $(cat files.txt)

I can say..I will not be installing that branch again until I can get clear instructions on how to install it properly. If you can give me some clear instructions please..i'd be very greatful.

(this issue can be closed after I get some clear instructions on what to with with the renamed branch)

dolfies commented 3 years ago

Generally, you don't want to install with setup.py. You would do pip install git+https://github.com/dolfies/discord.py-self.git@renamed

therealOri commented 3 years ago

@dolfies

Generally, you don't want to install with setup.py. You would do pip install git+https://github.com/dolfies/discord.py-self.git@renamed

I gave that a try and It installed just fine. But it wouldn't let me use the selfbot code and gave the usual "Improper token passed" error. But the normal discord bot code worked though. (yes I had both discord.py and discord.py-self(renamed) installed at the same time. I call that progress.).

I will say this was is better and gave less complications during install and uninstall.

dolfies commented 3 years ago

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

Do import selfcord as discord instead of import discord

therealOri commented 3 years ago

@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!.