1
votes
@bot.event
async def on_ready():
    print("Bot Online!")
    await bot.change_presence(activity = discord.Activity(type = discord.ActivityType.watching, name = "!help"))

bot.run('TOKEN')

I am getting this error on replit when I try to run this script:

Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 300, in static_login data = await self.request(Route('GET', '/users/@me')) Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 300, in static_login data = await self.request(Route('GET', '/users/@me')) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 254, 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 208, in bot.run('TOKEN') File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 723, in run return future.result() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 702, in runner await self.start(*args, **kwargs) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 665, in start await self.login(*args, bot=bot) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 511, in login await self.http.static_login(token.strip(), bot=bot) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 304, in static_login raise LoginFailure('Improper token has been passed.') from exc discord.errors.LoginFailure: Improper token has been passed.

1
Aren't you meant to put the actual token instead of TOKEN?mechanical_meat

1 Answers

1
votes

Your token needs to be replaced with an official bot token from discord, do this by going to discord dev portal and create a new application, after that click add bot, copy the token and paste where you have the word TOKEN

Example:

@bot.event
Async def on_ready():
    Print(‘Ready’)

Bot.run(‘2893613847hiu123fy8137gfy341gf’)