【发布时间】:2023-02-11 16:35:27
【问题描述】:
discord.py 有它自己的错误处理,但我需要处理 Python 错误。例子:
def create(a: str, b: str, c: str):
list = [a, b, c]
return list
@client.command()
async def test(ctx):
a = "First"
b = "Second"
list = create(a, b, c)
await ctx.send(list)
在命令使用时,我在终端中得到Command raised an exception: NameError: name 'c' is not defined,但我可以用它来处理吗
@client.event
async def on_error(ctx, error):
或者我需要在命令中使用try except循环?
【问题讨论】:
-
你可以使用你可以使用 try 和 except 块
标签: python error-handling discord.py