繁体   English   中英

'忽略命令中的异常无:discord.ext.commands.errors.CommandNotFound:未找到命令“测试”'Discord py中的错误

[英]'Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "test" is not found' error in Discord py

import discord
from discord.ext import commands
from discord.ext.commands import CommandNotFound

@client.event
async def on_ready():
    print('NCS is ready')

client.command()
async def test(ctx, test=str):
    await message.channel.send(account)


client.run("")

这是我想做的一个例子。 这是一个简单的事情,重复你说的第二件事。 唯一的问题是当我写 '.test' 时,它不起作用,我收到这个错误:

'Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "test" is not found

我知道如何删除此错误,但不知道如何修复它。 你能帮我么。 谢谢。

您忘记将command()设为装饰器。 此外,您将需要使用ctx.send ,并且您的account变量将在您的示例中未定义:

@client.command()
async def test(ctx, test=str):
    await ctx.send(account)

当你做一个命令时,你应该在开头添加@client.command() 在您的情况下,您忘记放置@ 因此,如果您这样做,您的问题将得到解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM