Merge pull request #386 from koreanbots/master

Bug fix
This commit is contained in:
Junseo Park 2021-05-29 01:27:52 +09:00 committed by GitHub
commit 86f17f523d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 11 deletions

@ -1 +1 @@
Subproject commit effc22ea2b191f7cfd35e08a4545bc7879e61d24
Subproject commit 6d23d8547697557601eb763eb3af9d318d2610d7

View File

@ -84,7 +84,7 @@ const BotCard: React.FC<BotCardProps> = ({ manage = false, bot }) => {
</a>
</Link>
{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>

View File

@ -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 })
})

View File

@ -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 })

View File

@ -2,7 +2,7 @@
<ShortName>한국 디스코드봇 리스트</ShortName>
<Description>국내 디스코드봇을 한 곳에서.</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">https://beta.koreanbots.dev/logo.png</Image>
<Url type="text/html" method="get" template="https://beta.koreanbots.dev/search?q={searchTerms}"/>
<moz:SearchForm>https://beta.koreanbots.dev/search</moz:SearchForm>
<Image width="16" height="16" type="image/x-icon">https://koreanbots.dev/logo.png</Image>
<Url type="text/html" method="get" template="https://koreanbots.dev/search?q={searchTerms}"/>
<moz:SearchForm>https://koreanbots.dev/search</moz:SearchForm>
</OpenSearchDescription>

View File

@ -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

View File

@ -47,7 +47,7 @@ async function getBot(id: string, owners=true):Promise<Bot> {
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))