mirror of
https://github.com/koreanbots/core.git
synced 2025-12-15 14:10:22 +00:00
feat:show strikes (#535)
* feat: add line break to invalid category * feat: show strikes * fix: typo * chore: wordings * feat: specify three reasons excluded
This commit is contained in:
parent
84eaaafde7
commit
3f5046b6c1
@ -54,6 +54,16 @@ const PendingBot: NextPage<PendingBotProps> = ({ data }) => {
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
<div className='pt-2'>
|
||||
{data.strikes < 3 ? (
|
||||
<p>
|
||||
앞으로 {3 - data.strikes}번의 심사 기회가 남았습니다. 심사 기회를 모두 소진하시면 동일한 봇으로의 심사가 제한됩니다. <br/>
|
||||
'프라이빗 봇', '봇 오프라인', '공식 디스코드 서버 미참여'로 거부된 경우 심사 기회가 차감되지 않습니다.
|
||||
</p>
|
||||
) : (
|
||||
<p>더 이상 해당 봇으로 심사를 신청하실 수 없습니다.</p>
|
||||
)}
|
||||
</div>
|
||||
</Message>
|
||||
}
|
||||
<p className='dark:text-gray-300 text-gray-800 text-base mt-3'>{data.intro}</p>
|
||||
@ -176,7 +186,10 @@ export const getServerSideProps = async (ctx: Context) => {
|
||||
const data = await get.botSubmit.load(JSON.stringify(ctx.query))
|
||||
return {
|
||||
props: {
|
||||
data
|
||||
data: data ? {
|
||||
...data,
|
||||
strikes: await get.botSubmitStrikes(data.id)
|
||||
} : null
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -195,7 +208,7 @@ const DenyPresetsArticle = {
|
||||
<p><strong>봇 오프라인</strong>으로 거부되셨다면 심사 당시에 봇이 오프라인으로 명령어가 응답하지 않았다는 뜻입니다.</p>
|
||||
<p>봇이 24시간 호스팅 되지 않는다면, 아쉽게도 저희가 심사 시간을 맞춰드릴 수 없기에 심사 시간과 봇의 온라인 시간이 맞지 않는다면 심사를 진행할 수 없습니다.</p>
|
||||
</>,
|
||||
INVALID_CATEGORY: <p>한 개 이상의 올바르지 않은 카테고리가 포함되어 있습니다. 반드시 <strong>봇에 해당되는</strong> 카테고리만 선택해주세요. 카테고리에 대한 자세한 설명은 <a className='text-blue-500 hover:text-blue-400' href='https://contents.koreanbots.dev/categories'>여기</a>에서 확인하실 수 있습니다.</p>,
|
||||
INVALID_CATEGORY: <p>한 개 이상의 올바르지 않은 카테고리가 포함되어 있습니다. 반드시 <strong>봇에 해당되는</strong> 카테고리만 선택해주세요. <br/>카테고리에 대한 자세한 설명은 <a className='text-blue-500 hover:text-blue-400' href='https://contents.koreanbots.dev/categories'>여기</a>에서 확인하실 수 있습니다.</p>,
|
||||
PRIVATE: <p>봇을 초대할 수 없어, 심사를 진행할 수 없습니다. 다음 항목을 확인해주세요.
|
||||
<ul className='list-inside list-disc'>
|
||||
<li>봇이 공개 봇인가요?</li>
|
||||
@ -209,7 +222,7 @@ const DenyPresetsArticle = {
|
||||
}
|
||||
|
||||
interface PendingBotProps {
|
||||
data: SubmittedBot
|
||||
data: SubmittedBot & {strikes: number | null}
|
||||
}
|
||||
|
||||
interface Context extends NextPageContext {
|
||||
|
||||
@ -407,8 +407,8 @@ async function submitBot(id: string, data: AddBotSubmit):Promise<1|2|3|4|5|Submi
|
||||
const submits = await knex('submitted').select(['id']).where({ state: 0 }).andWhere('owners', 'LIKE', `%${id}%`)
|
||||
if(submits.length > 1) return 1
|
||||
const botId = data.id
|
||||
const identicalSubmits = await knex('submitted').select(['id']).where({ id: botId, state: 2 }).whereNotIn('reason', ['PRIVATE', 'OFFLINE', 'ABSENT_AT_DISCORD']) // 다음 사유를 제외한 다른 사유의 3회 이상 거부 존재시 봇 등록 제한.
|
||||
if(identicalSubmits.length >= 3) return 5
|
||||
const strikes = await get.botSubmitStrikes(id)
|
||||
if(strikes >= 3) return 5
|
||||
const date = Math.round(+new Date()/1000)
|
||||
const sameID = await knex('submitted').select(['id']).where({ id: botId, state: 0 })
|
||||
const bot = await get.bot.load(data.id)
|
||||
@ -684,6 +684,14 @@ async function denyBotSubmission(id: string, date: number, reason?: string) {
|
||||
await knex('submitted').update({ state: 2, reason: reason || null }).where({ state: 0, id, date })
|
||||
}
|
||||
|
||||
async function getBotSubmitStrikes(id: string) {
|
||||
const identicalSubmits = await knex('submitted')
|
||||
.select(['id'])
|
||||
.where({ id, state: 2 })
|
||||
.whereNotIn('reason', ['PRIVATE', 'OFFLINE', 'ABSENT_AT_DISCORD']) // 다음 사유를 제외한 다른 사유의 3회 이상 거부 존재시 봇 등록 제한.
|
||||
return identicalSubmits.length
|
||||
}
|
||||
|
||||
async function approveBotSubmission(id: string, date: number) {
|
||||
const data = await knex('submitted').select(['id', 'date', 'category', 'lib', 'prefix', 'intro', 'desc', 'url', 'web', 'git', 'discord', 'state', 'owners', 'reason']).where({ state: 0, id, date })
|
||||
if(!data[0]) return false
|
||||
@ -836,6 +844,7 @@ export const get = {
|
||||
ServerAuthorization,
|
||||
botSubmitList: getBotSubmitList,
|
||||
botSubmitHistory: getBotSubmitHistory,
|
||||
botSubmitStrikes: getBotSubmitStrikes,
|
||||
serverOwners: fetchServerOwners
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user