UNPKG

koishi-plugin-beatsaber-bot

Version:

一个 用于 BeatSaber 的 koishi Bot 插件

39 lines (38 loc) 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IdSearchCmd = void 0; const koishi_1 = require("koishi"); function IdSearchCmd(ctx, cfg, render, api, logger) { const searchIdCmd = ctx .command('bsbot.id [mapId:string]') .alias('bbid') .alias('!bsr') .shortcut(/(^[0-9a-fA-F]{3,5}$)/, { args: ['$1'] }) .action(async ({ session, options }, input) => { if (!input || input && input.length < 1) { return; } const reg = /^[a-fA-F0-9]{1,6}$/; if (!reg.test(input)) { session.sendQuote(session.text('commands.bsbot.id.error-map-id', { input })); return; } const res = await api.BeatSaver.wrapperResult().searchMapById(input); if (!res.isSuccess()) { session.sendQuote(session.text('commands.bsbot.id.not-found', { input })); } else { let onStartRender = () => { session.send(session.text('common.render.wait', { sec: cfg.rankWaitTimeout / 1000 })); }; const image = await render.renderMap(res.data, onStartRender); await session.sendQueued(image); session.sendQueued(koishi_1.h.audio(res.data.versions[0].previewURL)); } }); return { key: 'id-search', cmd: searchIdCmd }; } exports.IdSearchCmd = IdSearchCmd;