Discordpy ctx send <discord.ext.commands.context.Context object at someid> 而不是实际命令
Discordpy ctx send <discord.ext.commands.context.Context object at someid> instead of the actual command
我试图在我的 discord 机器人上制造一个缺少参数的集中错误,但它没有像我预期的那样工作,这是代码
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send(f"Se necesitan argumentos `!help {ctx}` para verlos")
在我看来这应该是这样的
Se necesitan argumentos !help command para verlos
但结果是这样的
Se necesitan argumentos !help <discord.ext.commands.context.Context object at 0x7fba169585b0> para verlos
如何让它看起来像第一种情况?
如果是集中式错误处理程序,您无法知道触发错误的命令。通过将 <command_name>
作为字符串
的一部分来通知用户
这是一个例子:
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.MissingRequiredArguments):
await ctx.send('Se necesitan argumentos !help <command> para verlos')
是字符串的一部分。这样您就可以通知用户传递一个 command
参数,否则该命令将不起作用。
我试图在我的 discord 机器人上制造一个缺少参数的集中错误,但它没有像我预期的那样工作,这是代码
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send(f"Se necesitan argumentos `!help {ctx}` para verlos")
在我看来这应该是这样的
Se necesitan argumentos !help command para verlos
但结果是这样的
Se necesitan argumentos !help <discord.ext.commands.context.Context object at 0x7fba169585b0> para verlos
如何让它看起来像第一种情况?
如果是集中式错误处理程序,您无法知道触发错误的命令。通过将 <command_name>
作为字符串
这是一个例子:
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.MissingRequiredArguments):
await ctx.send('Se necesitan argumentos !help <command> para verlos')
command
参数,否则该命令将不起作用。