mirror of
https://github.com/koreanbots/core.git
synced 2025-12-17 06:40:24 +00:00
commit
86f17f523d
2
api-docs
2
api-docs
@ -1 +1 @@
|
|||||||
Subproject commit effc22ea2b191f7cfd35e08a4545bc7879e61d24
|
Subproject commit 6d23d8547697557601eb763eb3af9d318d2610d7
|
||||||
@ -84,7 +84,7 @@ const BotCard: React.FC<BotCardProps> = ({ manage = false, bot }) => {
|
|||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
{manage ? (
|
{manage ? (
|
||||||
<Link href={`/manage/${bot.id}`}>
|
<Link href={`/bots${bot.id}/edit`}>
|
||||||
<a className='py-3 w-full text-center text-green-500 hover:text-white text-sm font-bold hover:bg-green-500 rounded-br-2xl hover:shadow-lg transition duration-100 ease-in'>
|
<a className='py-3 w-full text-center text-green-500 hover:text-white text-sm font-bold hover:bg-green-500 rounded-br-2xl hover:shadow-lg transition duration-100 ease-in'>
|
||||||
관리하기
|
관리하기
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
import { NextApiRequest} from 'next'
|
import { NextApiRequest} from 'next'
|
||||||
import rateLimit from 'express-rate-limit'
|
import rateLimit from 'express-rate-limit'
|
||||||
|
import { MessageEmbed } from 'discord.js'
|
||||||
|
|
||||||
import { get, update } from '@utils/Query'
|
import { get, update } from '@utils/Query'
|
||||||
import RequestHandler from '@utils/RequestHandler'
|
import RequestHandler from '@utils/RequestHandler'
|
||||||
import ResponseWrapper from '@utils/ResponseWrapper'
|
import ResponseWrapper from '@utils/ResponseWrapper'
|
||||||
import { BotStatUpdate, BotStatUpdateSchema } from '@utils/Yup'
|
import { BotStatUpdate, BotStatUpdateSchema } from '@utils/Yup'
|
||||||
|
import { discordLog } from '@utils/DiscordBot'
|
||||||
|
import { KoreanbotsEndPoints } from '@utils/Constants'
|
||||||
|
import { makeDiscordCodeblock } from '@utils/Tools'
|
||||||
|
|
||||||
const limiter = rateLimit({
|
const limiter = rateLimit({
|
||||||
windowMs: 60 * 1000,
|
windowMs: 60 * 1000,
|
||||||
@ -37,6 +41,8 @@ const BotStats = RequestHandler()
|
|||||||
if(botInfo.id !== bot) return ResponseWrapper(res, { code: 403, version: 1 })
|
if(botInfo.id !== bot) return ResponseWrapper(res, { code: 403, version: 1 })
|
||||||
const d = await update.updateServer(botInfo.id, validated.servers)
|
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 })
|
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 })
|
return ResponseWrapper(res, { code: 200, message: '성공적으로 업데이트 했습니다.', version: 1 })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const BotVoted = RequestHandler()
|
|||||||
.get(async (req: ApiRequest, res) => {
|
.get(async (req: ApiRequest, res) => {
|
||||||
const bot = await get.BotAuthorization(req.headers.token)
|
const bot = await get.BotAuthorization(req.headers.token)
|
||||||
if(!bot) return ResponseWrapper(res, { code: 401, version: 1 })
|
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 })
|
if(!userID) return ResponseWrapper(res, { code: 400, version: 1 })
|
||||||
const result = await get.botVote(userID, bot)
|
const result = await get.botVote(userID, bot)
|
||||||
return res.json({ code: 200, voted: +new Date() < result + VOTE_COOLDOWN })
|
return res.json({ code: 200, voted: +new Date() < result + VOTE_COOLDOWN })
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<ShortName>한국 디스코드봇 리스트</ShortName>
|
<ShortName>한국 디스코드봇 리스트</ShortName>
|
||||||
<Description>국내 디스코드봇을 한 곳에서.</Description>
|
<Description>국내 디스코드봇을 한 곳에서.</Description>
|
||||||
<InputEncoding>UTF-8</InputEncoding>
|
<InputEncoding>UTF-8</InputEncoding>
|
||||||
<Image width="16" height="16" type="image/x-icon">https://beta.koreanbots.dev/logo.png</Image>
|
<Image width="16" height="16" type="image/x-icon">https://koreanbots.dev/logo.png</Image>
|
||||||
<Url type="text/html" method="get" template="https://beta.koreanbots.dev/search?q={searchTerms}"/>
|
<Url type="text/html" method="get" template="https://koreanbots.dev/search?q={searchTerms}"/>
|
||||||
<moz:SearchForm>https://beta.koreanbots.dev/search</moz:SearchForm>
|
<moz:SearchForm>https://koreanbots.dev/search</moz:SearchForm>
|
||||||
</OpenSearchDescription>
|
</OpenSearchDescription>
|
||||||
|
|||||||
@ -190,7 +190,7 @@ export const DiscordEnpoints = {
|
|||||||
export const KoreanbotsEndPoints = {
|
export const KoreanbotsEndPoints = {
|
||||||
OG: class {
|
OG: class {
|
||||||
static root = 'https://og.kbots.link'
|
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[]) {
|
static bot(id: string, name: string, bio: string, tags: string[], stats: string[]) {
|
||||||
const u = new URL(this.root)
|
const u = new URL(this.root)
|
||||||
u.pathname = name
|
u.pathname = name
|
||||||
|
|||||||
@ -47,7 +47,7 @@ async function getBot(id: string, owners=true):Promise<Bot> {
|
|||||||
const discordBot = await DiscordBot.users.fetch(res[0].id)
|
const discordBot = await DiscordBot.users.fetch(res[0].id)
|
||||||
await getMainGuild()?.members?.fetch(res[0].id).catch(e=> e)
|
await getMainGuild()?.members?.fetch(res[0].id).catch(e=> e)
|
||||||
if(!discordBot) return null
|
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].tag = discordBot.discriminator
|
||||||
res[0].avatar = discordBot.avatar
|
res[0].avatar = discordBot.avatar
|
||||||
res[0].name = discordBot.username
|
res[0].name = discordBot.username
|
||||||
@ -446,7 +446,7 @@ export const get = {
|
|||||||
const json = JSON.parse(k)
|
const json = JSON.parse(k)
|
||||||
return await getBotList('CATEGORY', json.page, json.category)
|
return await getBotList('CATEGORY', json.page, json.category)
|
||||||
}))).map(row => serialize(row))
|
}))).map(row => serialize(row))
|
||||||
, { cacheMap: new TLRU({ maxStoreSize: 50, maxAgeMs: 3000000 }) }),
|
, { cacheMap: new TLRU({ maxStoreSize: 50, maxAgeMs: 500000 }) }),
|
||||||
search: new DataLoader(
|
search: new DataLoader(
|
||||||
async (key: string[]) =>
|
async (key: string[]) =>
|
||||||
(await Promise.all(key.map(async (k: 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)
|
const res = await getBotList('SEARCH', json.page, json.query)
|
||||||
return { ...res, totalPage: Number(res.totalPage), currentPage: Number(res.currentPage) }
|
return { ...res, totalPage: Number(res.totalPage), currentPage: Number(res.currentPage) }
|
||||||
}))).map(row => serialize(row))
|
}))).map(row => serialize(row))
|
||||||
, { cacheMap: new TLRU({ maxStoreSize: 50, maxAgeMs: 3000000 }) }),
|
, { cacheMap: new TLRU({ maxStoreSize: 50, maxAgeMs: 500000 }) }),
|
||||||
votes: new DataLoader(
|
votes: new DataLoader(
|
||||||
async (pages: number[]) =>
|
async (pages: number[]) =>
|
||||||
(await Promise.all(pages.map(async (page: number) => await getBotList('VOTE', page)))).map(row => serialize(row))
|
(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(
|
new: new DataLoader(
|
||||||
async (pages: number[]) =>
|
async (pages: number[]) =>
|
||||||
(await Promise.all(pages.map(async (page: number) => await getBotList('NEW', page)))).map(row => serialize(row))
|
(await Promise.all(pages.map(async (page: number) => await getBotList('NEW', page)))).map(row => serialize(row))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user