捕获道具无法使用异常

This commit is contained in:
HibiKier 2025-02-22 23:58:51 +08:00 committed by GitHub
parent 62819ec90e
commit 8604444879
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,6 +18,7 @@ from nonebot_plugin_uninfo import Uninfo
from zhenxun.configs.utils import BaseBlock, Command, PluginExtraData, RegisterConfig
from zhenxun.services.log import logger
from zhenxun.utils.decorator.shop import NotMeetUseConditionsException
from zhenxun.utils.depends import UserName
from zhenxun.utils.enum import BlockType, PluginType
from zhenxun.utils.exception import GoodsNotFound
@ -202,6 +203,12 @@ async def _(
await MessageUtils.build_message(
f"没有找到道具 {name.result} 或道具数量不足..."
).send(reply_to=True)
except NotMeetUseConditionsException as e:
if info := e.get_info():
await MessageUtils.build_message(info).finish() # type: ignore
await MessageUtils.build_message(
f"使用道具 {name.result} 的条件不满足..."
).send(reply_to=True)
@_matcher.assign("gold-list")