Python discord.ext.commands.errors.MissingRequiredArgument:ctx是缺少的必需参数 #帮助命令 @client.command() 异步def帮助(前缀,ctx,键入_help=“None”): author=ctx.message.author 如果类型_help==“无”: embed=discord.embed(title=“Help Command”,value=“欢迎使用帮助命令。查看bot必须提供的各种类别!如果有,则为可选!如果有[],则为必需。此bot由!bobthefam#6969,color=discord.color.blue()制作) embed.add_字段(name=f“`{prefix}polls```”,value=“”,inline=False) 其他: embed=discord.embed(title=“Oops”,description=“我想你可能拼错了什么,再试一次”) 等待ctx.channel.send(author,embed=embed)

Python discord.ext.commands.errors.MissingRequiredArgument:ctx是缺少的必需参数 #帮助命令 @client.command() 异步def帮助(前缀,ctx,键入_help=“None”): author=ctx.message.author 如果类型_help==“无”: embed=discord.embed(title=“Help Command”,value=“欢迎使用帮助命令。查看bot必须提供的各种类别!如果有,则为可选!如果有[],则为必需。此bot由!bobthefam#6969,color=discord.color.blue()制作) embed.add_字段(name=f“`{prefix}polls```”,value=“”,inline=False) 其他: embed=discord.embed(title=“Oops”,description=“我想你可能拼错了什么,再试一次”) 等待ctx.channel.send(author,embed=embed),python,discord,discord.py,Python,Discord,Discord.py,我得到了标题中的错误。如何修复此问题?从第页您可以看到,实际上函数不使用前缀,而是命令使用前缀 您的代码应如下所示: client=commands.Bot(命令前缀='!') @client.command()#!调用命令的帮助 异步def帮助(ctx,键入_help=“None”): author=ctx.message.author [...] 从中,您可以通过为命令_prefix变量使用可调用(这是一种很好的表示函数;)来生成动态前缀 我猜是这样的: def my_custom_前缀

我得到了标题中的错误。如何修复此问题?

从第页您可以看到,实际上函数不使用前缀,而是命令使用前缀

您的代码应如下所示:


client=commands.Bot(命令前缀='!')
@client.command()#!调用命令的帮助
异步def帮助(ctx,键入_help=“None”):
author=ctx.message.author
[...]
从中,您可以通过为命令_prefix变量使用可调用(这是一种很好的表示函数;)来生成动态前缀

我猜是这样的:

def my_custom_前缀(bot,message):
#bot.commands包含所有可用的命令
匹配_command=[command.name用于bot.commands中的command,如果command.name用于消息中]
如果匹配_命令:
返回消息.split(匹配_命令[0])[0]
return“!”#我想您需要一个默认前缀以防
client=commands.Bot(command\u prefix=my\u custom\u prefix,不区分大小写=True)
@client.command()#{您想要的任何东西(默认情况下)}调用命令的帮助
异步def帮助(ctx,键入_help=“None”):
author=ctx.message.author
[...]

我有,但我想定制前缀。
#help command
@client.command()
async def help(prefix, ctx, type_help = "None"):
  author = ctx.message.author
  if type_help == "None":
    embed = discord.Embed(title = "Help Command", value = "Welcome to the Help Command. Look at the various categories the bot has to offer! If there is a <> it is optional! Also if there is a [], that is required. This bot is made by ! bobthefam#6969", color=discord.Colour.blue())
    embed.add_field(name = f"``{prefix}polls``", value = "", inline = False)
  else:
    embed = discord.Embed(title = "Oops", description = "I think you may have misspelled something. Try again")
            
  await ctx.channel.send(author, embed = embed)