mirror of
https://github.com/koreanbots/core.git
synced 2025-12-17 23:00:22 +00:00
feat: added shards field at bot
This commit is contained in:
parent
d96d543ec8
commit
67c961662b
@ -49,12 +49,12 @@ const BotStats = RequestHandler().post(limiter)
|
|||||||
ResponseWrapper(res, { code: 400, errors: e.errors })
|
ResponseWrapper(res, { code: 400, errors: e.errors })
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
|
|
||||||
if(!validated) return
|
if(!validated) return
|
||||||
const botInfo = await get.bot.load(req.query.id)
|
const botInfo = await get.bot.load(req.query.id)
|
||||||
if(!botInfo) return ResponseWrapper(res, { code: 404, message: '존재하지 않는 봇입니다.' })
|
if(!botInfo) return ResponseWrapper(res, { code: 404, message: '존재하지 않는 봇입니다.' })
|
||||||
if(botInfo.id !== bot) return ResponseWrapper(res, { code: 403 })
|
if(botInfo.id !== bot) return ResponseWrapper(res, { code: 403 })
|
||||||
const d = await update.updateServer(botInfo.id, validated.servers)
|
const d = await update.updateServer(botInfo.id, validated.servers, validated.shards)
|
||||||
if(d===1 || d===2) return ResponseWrapper(res, { code: 403, message: `서버 수를 ${[null, '1만', '100만'][d]} 이상으로 설정하실 수 없습니다. 문의해주세요.` })
|
if(d===1 || d===2) return ResponseWrapper(res, { code: 403, message: `서버 수를 ${[null, '1만', '100만'][d]} 이상으로 설정하실 수 없습니다. 문의해주세요.` })
|
||||||
get.bot.clear(req.query.id)
|
get.bot.clear(req.query.id)
|
||||||
await getStatsLoggingChannel().send(`[BOT/STATS] <@${botInfo.id}> (${botInfo.id})\n${makeDiscordCodeblock(`${botInfo.servers > validated.servers ? '-' : '+'} ${botInfo.servers} -> ${validated.servers} (${botInfo.servers > validated.servers ? '▼' : '▲'}${Math.abs(validated.servers - botInfo.servers)})`, 'diff')}`, (new MessageEmbed().setDescription(`${botInfo.name} - <@${botInfo.id}> ([${botInfo.id}](${KoreanbotsEndPoints.URL.bot(botInfo.id)}))`)))
|
await getStatsLoggingChannel().send(`[BOT/STATS] <@${botInfo.id}> (${botInfo.id})\n${makeDiscordCodeblock(`${botInfo.servers > validated.servers ? '-' : '+'} ${botInfo.servers} -> ${validated.servers} (${botInfo.servers > validated.servers ? '▼' : '▲'}${Math.abs(validated.servers - botInfo.servers)})`, 'diff')}`, (new MessageEmbed().setDescription(`${botInfo.name} - <@${botInfo.id}> ([${botInfo.id}](${KoreanbotsEndPoints.URL.bot(botInfo.id)}))`)))
|
||||||
|
|||||||
@ -179,6 +179,14 @@ const Bots: NextPage<BotsProps> = ({ data, desc, date, user, theme, csrfToken })
|
|||||||
<i className='fas fa-users' /> 서버수
|
<i className='fas fa-users' /> 서버수
|
||||||
</div>
|
</div>
|
||||||
<div>{data.servers || 'N/A'}</div>
|
<div>{data.servers || 'N/A'}</div>
|
||||||
|
{
|
||||||
|
data.shards && data.servers > 1500 && <>
|
||||||
|
<div>
|
||||||
|
<i className='fas fa-sitemap' /> 샤드수
|
||||||
|
</div>
|
||||||
|
<div>{data.shards}</div>
|
||||||
|
</>
|
||||||
|
}
|
||||||
<div>
|
<div>
|
||||||
<i className='fas fa-calendar-day' /> 봇 생성일
|
<i className='fas fa-calendar-day' /> 봇 생성일
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -13,6 +13,7 @@ export interface Bot {
|
|||||||
prefix: string
|
prefix: string
|
||||||
votes: number
|
votes: number
|
||||||
servers: number
|
servers: number
|
||||||
|
shards: number
|
||||||
intro: string
|
intro: string
|
||||||
desc: string
|
desc: string
|
||||||
category: Category[]
|
category: Category[]
|
||||||
|
|||||||
@ -25,6 +25,7 @@ async function getBot(id: string, owners=true):Promise<Bot> {
|
|||||||
'prefix',
|
'prefix',
|
||||||
'votes',
|
'votes',
|
||||||
'servers',
|
'servers',
|
||||||
|
'shards',
|
||||||
'intro',
|
'intro',
|
||||||
'desc',
|
'desc',
|
||||||
'web',
|
'web',
|
||||||
@ -280,12 +281,14 @@ async function updateBot(id: string, data: ManageBot) {
|
|||||||
/**
|
/**
|
||||||
* @returns 1 - Limit of 100k servers
|
* @returns 1 - Limit of 100k servers
|
||||||
* @returns 2 - Limit of 10M servers
|
* @returns 2 - Limit of 10M servers
|
||||||
|
* @returns 3 - Limit of 100 shards
|
||||||
*/
|
*/
|
||||||
async function updateServer(id: string, servers: number) {
|
async function updateServer(id: string, servers: number, shards: number) {
|
||||||
const bot = await get.bot.load(id)
|
const bot = await get.bot.load(id)
|
||||||
if(bot.servers < 10000 && servers >= 10000) return 1
|
if(bot.servers < 10000 && servers >= 10000) return 1
|
||||||
if(bot.servers < 1000000 && servers >= 1000000) return 2
|
else if(bot.servers < 1000000 && servers >= 1000000) return 2
|
||||||
await knex('bots').update({ servers }).where({ id })
|
if(bot.shards < 200 && shards >= 200) return 3
|
||||||
|
await knex('bots').update({ servers: servers === undefined ? bot.servers : servers, shards: shards === undefined ? bot.shards : shards }).where({ id })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -194,11 +194,18 @@ export const BotStatUpdateSchema: Yup.SchemaOf<BotStatUpdate> = Yup.object({
|
|||||||
servers: Yup.number()
|
servers: Yup.number()
|
||||||
.positive('서버 수는 양수여야합니다.')
|
.positive('서버 수는 양수여야합니다.')
|
||||||
.integer('서버 수는 정수여야합니다.')
|
.integer('서버 수는 정수여야합니다.')
|
||||||
.required()
|
.max(1000000000000)
|
||||||
|
.nullable(),
|
||||||
|
shards: Yup.number()
|
||||||
|
.positive('샤드 수는 양수여야합니다.')
|
||||||
|
.integer('샤드 수는 정수여야합니다.')
|
||||||
|
.max(10000)
|
||||||
|
.nullable(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export interface BotStatUpdate {
|
export interface BotStatUpdate {
|
||||||
servers: number
|
servers: number
|
||||||
|
shards: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ReportSchema: Yup.SchemaOf<Report> = Yup.object({
|
export const ReportSchema: Yup.SchemaOf<Report> = Yup.object({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user