diff --git a/api-docs b/api-docs index effc22e..6d23d85 160000 --- a/api-docs +++ b/api-docs @@ -1 +1 @@ -Subproject commit effc22ea2b191f7cfd35e08a4545bc7879e61d24 +Subproject commit 6d23d8547697557601eb763eb3af9d318d2610d7 diff --git a/components/BotCard.tsx b/components/BotCard.tsx index fd90048..e370c46 100644 --- a/components/BotCard.tsx +++ b/components/BotCard.tsx @@ -84,7 +84,7 @@ const BotCard: React.FC = ({ manage = false, bot }) => { {manage ? ( - + 관리하기 diff --git a/pages/api/v1/bots/servers.ts b/pages/api/v1/bots/servers.ts index 5fdd46f..71ad865 100644 --- a/pages/api/v1/bots/servers.ts +++ b/pages/api/v1/bots/servers.ts @@ -1,10 +1,14 @@ import { NextApiRequest} from 'next' import rateLimit from 'express-rate-limit' +import { MessageEmbed } from 'discord.js' import { get, update } from '@utils/Query' import RequestHandler from '@utils/RequestHandler' import ResponseWrapper from '@utils/ResponseWrapper' import { BotStatUpdate, BotStatUpdateSchema } from '@utils/Yup' +import { discordLog } from '@utils/DiscordBot' +import { KoreanbotsEndPoints } from '@utils/Constants' +import { makeDiscordCodeblock } from '@utils/Tools' const limiter = rateLimit({ windowMs: 60 * 1000, @@ -37,6 +41,8 @@ const BotStats = RequestHandler() if(botInfo.id !== bot) return ResponseWrapper(res, { code: 403, version: 1 }) const d = await update.updateServer(botInfo.id, validated.servers) if(d===1 || d===2) return ResponseWrapper(res, { code: 403, message: `서버 수를 ${[null, '1만', '100만'][d]} 이상으로 설정하실 수 없습니다. 문의해주세요.`, version: 1 }) + get.bot.clear(bot) + await discordLog('BOT/STATS', botInfo.id, (new MessageEmbed().setDescription(`${botInfo.name} - <@${botInfo.id}> ([${botInfo.id}](${KoreanbotsEndPoints.URL.bot(botInfo.id)}))`)), null, makeDiscordCodeblock(`${botInfo.servers > validated.servers ? '-' : '+'} ${botInfo.servers} -> ${validated.servers} (${botInfo.servers > validated.servers ? '▼' : '▲'}${Math.abs(validated.servers - botInfo.servers)})`, 'diff')) return ResponseWrapper(res, { code: 200, message: '성공적으로 업데이트 했습니다.', version: 1 }) }) diff --git a/pages/api/v1/bots/voted/[id].ts b/pages/api/v1/bots/voted/[id].ts index 659d0bb..28afbfb 100644 --- a/pages/api/v1/bots/voted/[id].ts +++ b/pages/api/v1/bots/voted/[id].ts @@ -9,7 +9,7 @@ const BotVoted = RequestHandler() .get(async (req: ApiRequest, res) => { const bot = await get.BotAuthorization(req.headers.token) if(!bot) return ResponseWrapper(res, { code: 401, version: 1 }) - const userID = await Yup.string().required().validate(bot).then(el => el).catch(() => null) + const userID = await Yup.string().required().validate(req.query.id).then(el => el).catch(() => null) if(!userID) return ResponseWrapper(res, { code: 400, version: 1 }) const result = await get.botVote(userID, bot) return res.json({ code: 200, voted: +new Date() < result + VOTE_COOLDOWN }) diff --git a/public/opensearch.xml b/public/opensearch.xml index 96c5648..a69d877 100644 --- a/public/opensearch.xml +++ b/public/opensearch.xml @@ -2,7 +2,7 @@ 한국 디스코드봇 리스트 국내 디스코드봇을 한 곳에서. UTF-8 - https://beta.koreanbots.dev/logo.png - - https://beta.koreanbots.dev/search + https://koreanbots.dev/logo.png + + https://koreanbots.dev/search diff --git a/utils/Constants.ts b/utils/Constants.ts index a0e32c6..612a541 100644 --- a/utils/Constants.ts +++ b/utils/Constants.ts @@ -190,7 +190,7 @@ export const DiscordEnpoints = { export const KoreanbotsEndPoints = { OG: class { static root = 'https://og.kbots.link' - static origin = 'https://beta.koreanbots.dev' + static origin = 'https://koreanbots.dev' static bot(id: string, name: string, bio: string, tags: string[], stats: string[]) { const u = new URL(this.root) u.pathname = name diff --git a/utils/Query.ts b/utils/Query.ts index 759322b..1a16fd8 100644 --- a/utils/Query.ts +++ b/utils/Query.ts @@ -47,7 +47,7 @@ async function getBot(id: string, owners=true):Promise { const discordBot = await DiscordBot.users.fetch(res[0].id) await getMainGuild()?.members?.fetch(res[0].id).catch(e=> e) if(!discordBot) return null - res[0].flags = res[0].flags | (discordBot.flags && DiscordUserFlags.VERIFIED_BOT ? BotFlags.verified : 0) | (res[0].trusted ? BotFlags.trusted : 0) | (res[0].partnered ? BotFlags.partnered : 0) + res[0].flags = res[0].flags | (discordBot.flags.bitfield && DiscordUserFlags.VERIFIED_BOT ? BotFlags.verified : 0) | (res[0].trusted ? BotFlags.trusted : 0) | (res[0].partnered ? BotFlags.partnered : 0) res[0].tag = discordBot.discriminator res[0].avatar = discordBot.avatar res[0].name = discordBot.username @@ -446,7 +446,7 @@ export const get = { const json = JSON.parse(k) return await getBotList('CATEGORY', json.page, json.category) }))).map(row => serialize(row)) - , { cacheMap: new TLRU({ maxStoreSize: 50, maxAgeMs: 3000000 }) }), + , { cacheMap: new TLRU({ maxStoreSize: 50, maxAgeMs: 500000 }) }), search: new DataLoader( async (key: string[]) => (await Promise.all(key.map(async (k: string) => { @@ -454,11 +454,11 @@ export const get = { const res = await getBotList('SEARCH', json.page, json.query) return { ...res, totalPage: Number(res.totalPage), currentPage: Number(res.currentPage) } }))).map(row => serialize(row)) - , { cacheMap: new TLRU({ maxStoreSize: 50, maxAgeMs: 3000000 }) }), + , { cacheMap: new TLRU({ maxStoreSize: 50, maxAgeMs: 500000 }) }), votes: new DataLoader( async (pages: number[]) => (await Promise.all(pages.map(async (page: number) => await getBotList('VOTE', page)))).map(row => serialize(row)) - , { cacheMap: new TLRU({ maxStoreSize: 50, maxAgeMs: 3000000 }) }), + , { cacheMap: new TLRU({ maxStoreSize: 50, maxAgeMs: 500000 }) }), new: new DataLoader( async (pages: number[]) => (await Promise.all(pages.map(async (page: number) => await getBotList('NEW', page)))).map(row => serialize(row))