from core.builtins.message import MessageSession from core.component import on_command from .dice import roll dice = on_command('dice', alias={'d4': 'dice d4', 'd6': 'dice d6', 'd8': 'dice d8', 'd10': 'dice d10', 'd12': 'dice d12', 'd20': 'dice d20', 'd100': 'dice d100'}, developers=['Light-Beacon'], desc='随机骰子',) @dice.handle(' [] {投掷指定骰子,可指定 dc 判断判定。}',) async def _(msg: MessageSession): dice = msg.parsed_msg[''] dc = msg.parsed_msg.get('', '0') if not dc.isdigit(): await msg.finish('发生错误:无效的 dc:' + dc) await msg.finish(await roll(dice, int(dc)))