dolfies / discord.py-self

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

discord.errors.LoginFailure: Improper token has been passed. #357

Closed floorshame closed 2 years ago

floorshame commented 2 years ago

Summary

discord.errors.LoginFailure: Improper token has been passed.

Reproduction Steps

Code

import selfcord as discord
from discord.ext import commands

bot = commands.Bot(command_prefix='>', self_bot=True)

@bot.command()
async def ping(ctx):
    await ctx.send('pong')

bot.run('mytoken')

Expected Results

For it to login into my acount, then when i run ping it will reply with pong

Actual Results

Traceback (most recent call last): File "C:\Users\me\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 406, in static_login data = await self.request(Route("GET", "/users/@me")) File "C:\Users\me\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 359, in request raise HTTPException(response, 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:\Users\me\OneDrive\Desktop\rainbot.py", line 10, in bot.run('mytoken') File "C:\Users\me\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 715, in run return future.result() File "C:\Users\me\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 694, in runner await self.start(*args, **kwargs) File "C:\Users\me\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 657, in start await self.login(token) File "C:\Users\me\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 514, in login data = await self.http.static_login(token.strip()) File "C:\Users\me\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 410, in static_login raise LoginFailure("Improper token has been passed.") from exc discord.errors.LoginFailure: Improper token has been passed.

System Information

Checklist

Additional Information

No response

floorshame commented 2 years ago

issue fixed its self? not sure why maybe look into it though

floorshame commented 2 years ago

To fix this issue follow these steps lmao: git clone https://github.com/dolfies/discord.py-self cd discord.py-self pip install -U .[voice] pip uninstall discord.py-self pip install discord.py-self

dolfies commented 2 years ago

You're importing selfcord (which gets you discord.py-self), but you're importing the commands ext from discord, which I'm assuming is the original, bot-only discord.py.

Either import the ext from selfcord, or uninstall discord.py and install discord.py-self.

ak4zh commented 1 year ago

I am also randomly getting discord.errors.LoginFailure: Improper token has been passed for a running bot. So I add token and randomly it get's invalidated without me calling logout. I have to generate the fresh token to make it work again.