是否可以从不和谐的机器人中打印出 IndexError?
Is it possible to print out an IndexError from a discord bot?
如果执行不正确,我想从我的 Discord 机器人打印出来并 IndexError("List index out of range")
到一个频道。但是,我也用于 AttributeErrors
的方法不起作用。我哪里出错了?
try:
message = await channel.fetch_message(id_)
except IndexError:
return await ctx.send('The ID that was entered was incorrect, make sure you have entered the correct giveaway message ID.')
Messageable.fetch_message
从不引发 IndexError
,它引发以下内容:
discord.Notfound
- 如果找不到消息
discord.Forbidden
- 如果您没有所需的权限
discord.HTTPException
- 检索消息失败时
回答你的问题 - 你可以简单地排除 discord.NotFound
错误
try:
message = await channel.fetch_message(message_id)
except discord.NotFound:
await ctx.send("The ID that was entered is incorrect, make sure you have entered the correct giveaway message ID.")
如果执行不正确,我想从我的 Discord 机器人打印出来并 IndexError("List index out of range")
到一个频道。但是,我也用于 AttributeErrors
的方法不起作用。我哪里出错了?
try:
message = await channel.fetch_message(id_)
except IndexError:
return await ctx.send('The ID that was entered was incorrect, make sure you have entered the correct giveaway message ID.')
Messageable.fetch_message
从不引发 IndexError
,它引发以下内容:
discord.Notfound
- 如果找不到消息discord.Forbidden
- 如果您没有所需的权限discord.HTTPException
- 检索消息失败时
回答你的问题 - 你可以简单地排除 discord.NotFound
错误
try:
message = await channel.fetch_message(message_id)
except discord.NotFound:
await ctx.send("The ID that was entered is incorrect, make sure you have entered the correct giveaway message ID.")