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
我知道如何删除此错误,但无法解决。你能帮我么。谢谢。
答案 0 :(得分:2)
您忘记将command()
用作装饰器。另外,您将要使用ctx.send
,并且您的account
变量在示例中将是未定义的:
@client.command()
async def test(ctx, test=str):
await ctx.send(account)
答案 1 :(得分:0)
发出命令时,应在开始处添加@client.command()
。就您而言,您忘记放置@
。因此,如果您这样做,您的问题将得到解决。