How to solve the problem?


import random
import discord
from discord.ext import commands
from asyncio import sleep
client= commands.Bot(command_prefix=PREFIX)
async def ehelp(ctx):
    embed= discord.Embed(color=0xff0000, title='Title')
    embed.add_field(name='name', value='value', inline=False)
    embed.add_field(name='name', value='value', inline=False)
    await ctx.send(embed=embed)


Traceback (most recent call last):
  File "/home/container/.local/lib/python3.8/site-packages/discord/http.py", line 293, in static_login
    data= await self.request(Route('GET', '/users/@me'))
  File "/home/container/.local/lib/python3.8/site-packages/discord/http.py", line 247, 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 "bot.py", line 18, in <module>    client.run('token')
  File "/home/container/.local/lib/python3.8/site-packages/discord/client.py", line 718, in run
    return future.result()
  File "/home/container/.local/lib/python3.8/site-packages/discord/client.py", line 697, in runner
    await self.start(*args, **kwargs)
  File "/home/container/.local/lib/python3.8/site-packages/discord/client.py", line 660, in start
    await self.login(*args, bot=bot)
  File "/home/container/.local/lib/python3.8/site-packages/discord/client.py", line 509, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "/home/container/.local/lib/python3.8/site-packages/discord/http.py", line 297, in static_login
    raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.

it seems to me that instead of the string 'token' you tried to pass a variable. The obvious mistake

Crazy Theory2022-01-21 13:27:13

and yes, no need to fire the token from the bot here. Make an empty line in the code block.

Crazy Theory2022-01-21 13:27:13