'Python discord bot, command not found
Why am I getting this error: Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "Test" is not found
I saw other posts about this but the problem was them either not having their token or the bot.run(TOKEN) at the bottom
*EDIT Here's the updated code, still get the same error
import discord
from dotenv import load_dotenv
from discord.ext import commands
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
bot = commands.Bot(command_prefix='$', case_insensitive=True)
@bot.event
async def on_ready():
for guild in bot.guilds:
if guild.name == GUILD:
break
print(
f'{bot.user} is connected to the following guild:\n'
f'{guild.name}(id: {guild.id})'
)
@bot.command()
async def on_message(ctx, arg):
if ctx.author == bot.user:
return
if ctx.content.startswith('hello'):
await ctx.channel.send(arg)
bot.run(TOKEN)
bot.run(TOKEN)
Solution 1:[1]
your code is basically right.
There's a "spelling" mistake in the command that you wrote in the chat.
You should use $test instead of $Test while entering the command.
However, you can avoid these mistakes by setting case_insensitive to True
With your example it would look like this:
bot = commands.Bot(command_prefix='$', case_insensitive=True)
This should work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | renaxdev |
