UNPKG

koishi-plugin-kbot

Version:
46 lines (45 loc) 1.62 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.guildRoutes = void 0; const utils_1 = __importDefault(require("../utils")); function getGuildWatchList(context) { return async (ctx) => { const channelInfo = await context.database.get('channel', { platform: 'onebot' }); ctx.body = channelInfo.map((channel) => { return { guildId: +channel.guildId, isWatch: channel.watchDelete, }; }); }; } function getSetGuildWatch(context) { return async (ctx) => { const { guildId, isWatch } = ctx.query; const channel = await context.database.get('channel', { id: guildId, platform: 'onebot', guildId }); if (channel.length === 0) { ctx.body = false; } else { await context.database.upsert('channel', [{ id: guildId, platform: 'onebot', guildId: guildId, watchDelete: +isWatch === 1 }]); ctx.body = true; } }; } exports.guildRoutes = { '/setGuildWatch': function (context) { return getSetGuildWatch(context); }, '/guildWatchList': function (context) { return getGuildWatchList(context); }, '/guildList': function (context) { return (0, utils_1.default)(context, 'getGuildList', 'botId'); }, '/guildMemberList': function (context) { return (0, utils_1.default)(context, 'getGuildMemberList', 'botId', 'guildId'); }, };