[英]I'm having a problem using discord.py, one of my commands won't get recognized
Here's the thing, i'm using the latest version of discord.py to write a discord bot, and i'm stuck事情是这样的,我正在使用最新版本的 discord.py 来编写 discord 机器人,我被卡住了
I've made a custom help command and before that i have removed the old help command using this line:我已经制作了一个自定义帮助命令,在此之前我已经使用这一行删除了旧的帮助命令:
client.remove_command("help")
Although when i run it, (it spits no errors btw) and try the command, it says虽然当我运行它时(顺便说一句,它没有吐出错误)并尝试该命令,但它说
discord.ext.commands.errors.CommandNotFound: Command "help" is not found discord.ext.commands.errors.CommandNotFound:找不到命令“帮助”
Here's the full code:这是完整的代码:
import discord
from discord.ext import commands
client = commands.Bot(command_prefix = '.')
client.remove_command("help")
@client.event
async def on_ready():
print('bot is ready.')
client.command(pass_context=True)
async def help(ctx, member : discord.Member):
author = ctx.message.author
embed = discord.Embed(
colour = discord.Colour.orange()
)
embed.set_author(name='Help', value="Sends you this embed in a private message")
embed.add_field(name='.ping', value="Shows the bot's current ping.", inline=False)
await author.send(embed=embed)
await ctx.send(f"{member.mention} Check you dms, i've sent you a private message! *wink*")
client.run('TOKEN HERE')
You are missing an "@" before client.command(pass_context=True)
您在
client.command(pass_context=True)
之前缺少一个“@”
This means that you do successfully remove the default help command but then because of that typo your custom help command is never created.这意味着您确实成功地删除了默认帮助命令,但是由于那个拼写错误,您的自定义帮助命令永远不会创建。 So when you try to run the help command it says that it doesn't exist.
因此,当您尝试运行帮助命令时,它会说它不存在。
discord.py 1.4.0 documentation on defining a command: https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html discord.py 1.4.0 关于定义命令的文档: https://discordpy.readthedocs.io/en/latest/ext/commands/commands.ZFC35FDC70D5FC69D769883A82E2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.