What do I do if get an ‘Improper Token has been passed’ error?

  discord, pycord, python

The problem:

I’m making a Discord bot with Pycord which has a simple greeting command.
Here is my code:

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='b?')

async def hello(ctx):
    ctx.send('Hi there!')


However, I get this error

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

My actual bot token is in the place of ‘TOKEN’, but it still gives the same error.

I have tried:

  • Checking if the bot token is correct again
  • Deleting the application itself, creating a new one, then using the token for that
  • Copying the token from the Bot page, instead of copying the client secret, application id, etc.

But it still shows the same error.

Source: Python Questions