How i can fix it

Traceback (most recent call last):
  File "/home/runner/DiscordBot-1/venv/lib/python3.10/site-packages/discord/http.py", line 801, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "/home/runner/DiscordBot-1/venv/lib/python3.10/site-packages/discord/http.py", line 744, 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 "main.py", line 36, in <module>
    client.run('TOKEN')
  File "/home/runner/DiscordBot-1/venv/lib/python3.10/site-packages/discord/client.py", line 860, in run
    asyncio.run(runner())
  File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/runner/DiscordBot-1/venv/lib/python3.10/site-packages/discord/client.py", line 849, in runner
    await self.start(token, reconnect=reconnect)
  File "/home/runner/DiscordBot-1/venv/lib/python3.10/site-packages/discord/client.py", line 777, in start
    await self.login(token)
  File "/home/runner/DiscordBot-1/venv/lib/python3.10/site-packages/discord/client.py", line 612, in login
    data = await self.http.static_login(token)
  File "/home/runner/DiscordBot-1/venv/lib/python3.10/site-packages/discord/http.py", line 805, in static_login
    raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.

You passed a bad token. That is why you are getting this error. Try re-setting your token in the discord developer portal.

2 Likes

If i try to reset the token, i have a messsage “The resource is being rate limited.”

Can you please provide a link to the repl? And maybe a screenshot to the discord page as long as nothing private is showing.

Sry my english is not good but do u mean the code and the screenshot from discord devolper portal?

1 Like

I mean the link to the code, and the screenshot from discord devolper portal

i did it right now and it works but i have the same problem with the token. The token is in .env idk what i did wrong

1 Like
  1. The token should be in replit secrets not a .env file
  2. It is the token, not the 2fa
  3. You still have not given the repl link

im pretty sure you gotta go to secrets to do that in the reply i was having the same problem

https://replit.com/@DarlingFire/DiscordBot-1#main.py here sorry i forgett it

so can u show me how where i should paste in the secret code

1 Like

Follow the tutorial I linked, and then at the very top add import os and at the very bottom replace client.run('TOKEN') with client.run(os.getenv('TOKEN')). And please, never use requests for a discord bot, it is blocking and you should use aiohttp instead.

1 Like

ok thank you so much.

Im a beginner in this and sorry for so many questions. I have only 1 question. I dont know what im created but will that the bot send me information about a sneaker from stockx . I cant prove if it works and what do you would recomend for the code

I will try and fork your repl to fix the requests thing! I also realized another mistake so I will fix that too

Edit: Here is the should be fixed version: main.py · GitHub

Thank you and sorry again.I hope it will work and if not i will write you :wink:

1 Like

ok ok sry again but new problem

Traceback (most recent call last):
File “main.py”, line 6, in
bot = commands.Bot(intents=intents)
TypeError: BotBase.init() missing 1 required positional argument: ‘command_prefix’

Sorry, my bad! I updated the previous link, try it again.

hm again problem

Traceback (most recent call last):
File “main.py”, line 16, in
async def stockx(ctx):
File “/home/runner/DiscordBot-1/venv/lib/python3.10/site-packages/discord/client.py”, line 1986, in event
raise TypeError(‘event registered must be a coroutine function’)
TypeError: event registered must be a coroutine function

try removing the second @bot.event ( I also updated the gist)