[英]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
为什么我收到此错误:
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我看到了关于此的其他帖子,但问题是他们要么没有令牌,要么底部没有
bot.run(TOKEN)
*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)
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.输入命令时,您应该使用
$test
而不是$Test
。 However, you can avoid these mistakes by setting case_insensitive
to True
但是,您可以通过将
case_insensitive
设置为True
来避免这些错误
With your example it would look like this:在您的示例中,它看起来像这样:
bot = commands.Bot(command_prefix='$', case_insensitive=True)
This should work这应该工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.