koishi-plugin-beatsaber-bot
Version:
一个 用于 BeatSaber 的 koishi Bot 插件
35 lines (34 loc) • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.scoresaber = void 0;
const scoresaber = async (ctx, api, { session, options }, input) => {
const scoresaberSubScribe = await ctx.database.get('BSBotSubscribe', {
type: 'scoresaber',
selfId: session.selfId,
platform: session.platform,
channelId: session.channelId,
});
if (scoresaberSubScribe.length > 0) {
const sub = scoresaberSubScribe[0];
if (sub.enable) {
session.sendQuote(session.text('commands.bsbot.subscribe.scoresaber.exist'));
return;
}
let data = { ...sub, enable: true };
await ctx.database.upsert('BSBotSubscribe', [data]);
session.sendQuote(session.text('commands.bsbot.subscribe.scoresaber.success'));
return;
}
const sub = {
channelId: session.channelId,
selfId: session.selfId,
platform: session.platform,
uid: session.uid,
enable: true,
type: 'scoresaber',
data: {}
};
await ctx.database.upsert('BSBotSubscribe', [sub]);
session.sendQuote(session.text('commands.bsbot.subscribe.scoresaber.success'));
};
exports.scoresaber = scoresaber;