这就是问题,我正在使用最新版本的discord.py编写一个discord机器人,但我被卡住了
我做了一个自定义的帮助命令,在此之前,我已经使用此行删除了旧的帮助命令:
client.remove_command("help")
虽然我运行它,(顺便说一下,它不会吐出任何错误)并尝试命令,但它说
discord.ext.commands.errors.CommandNotFound:找不到命令“帮助”
这是完整的代码:
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')
答案 0 :(得分:0)
您在client.command(pass_context=True)
之前缺少“ @”
这意味着您确实成功删除了默认帮助命令,但是由于这种错字,您的自定义帮助命令从未创建。因此,当您尝试运行help命令时,它说该命令不存在。
discord.py 1.4.0有关定义命令的文档:https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html