它还没有完成,但是我正在向我的机器人添加一项民意调查功能。但是,如果没有问题或选项,我希望能够做点什么。我不想做一个错误处理程序,因为我觉得它远远超出了我所知道的范围。
@bot.command(pass_context=True)
async def poll(ctx, *, msg):
try:
split_msg = msg.split(";")
question = split_msg[0]
option1 = split_msg[1]
option2 = split_msg[2]
embed = discord.Embed(title="Question", description=question)
embed.add_field(name="Option 1", value=option1, inline=True)
embed.add_field(name="Option 2", value=option2, inline=True)
error = discord.Embed(title=":warning: Incorrect Syntax!", description="Usage: {}poll <question>; <option1>; <option2>".format(prefix))
await bot.say(embed=embed)
except CommandInvokeError:
print("CommandInvokeError")
答案 0 :(得分:0)
不。 CommandInvokeError
是机器人在命令执行引发任何未捕获的错误时调用命令所引发的异常。您的代码不会引发CommandInvokeError
,因此您无法捕获它。如果您查看完整的错误消息,则很可能会发现CommandInvokeError
是由另一个错误引起的,可以捕获。