mirror of
https://github.com/koreanbots/core.git
synced 2025-12-15 14:10:22 +00:00
feat: added approve api
This commit is contained in:
parent
4b8beb9713
commit
a2c1347387
37
pages/api/v2/management/bots/submits/[id]/[date]/approve.ts
Normal file
37
pages/api/v2/management/bots/submits/[id]/[date]/approve.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { NextApiRequest } from 'next'
|
||||
import { MessageEmbed } from 'discord.js'
|
||||
|
||||
import RequestHandler from '@utils/RequestHandler'
|
||||
import ResponseWrapper from '@utils/ResponseWrapper'
|
||||
import { get, update } from '@utils/Query'
|
||||
import { DiscordBot, getBotReviewLogChannel } from '@utils/DiscordBot'
|
||||
import { KoreanbotsEndPoints } from '@utils/Constants'
|
||||
|
||||
const ApproveBotSubmit = RequestHandler()
|
||||
.post(async (req: ApiRequest, res) => {
|
||||
const bot = await get.BotAuthorization(req.headers.authorization)
|
||||
if(bot !== DiscordBot.user.id) return ResponseWrapper(res, { code: 403 })
|
||||
const submit = await get.botSubmit.load(JSON.stringify({ id: req.query.id, date: req.query.date }))
|
||||
if(!submit) return ResponseWrapper(res, { code: 404 })
|
||||
if(submit.state !== 0) return ResponseWrapper(res, { code: 400, message: '대기 중이지 않은 아이디입니다.' })
|
||||
const result = await update.approveBotSubmission(submit.id, submit.date)
|
||||
if(!result) return ResponseWrapper(res, { code: 400 })
|
||||
get.botSubmit.clear(JSON.stringify({ id: req.query.id, date: req.query.date }))
|
||||
get.bot.clear(req.query.id)
|
||||
const embed = new MessageEmbed().setTitle('승인').setColor('GREEN').setDescription(`[${submit.id}/${submit.date}](${KoreanbotsEndPoints.URL.submittedBot(submit.id, submit.date)})`).setTimestamp()
|
||||
if(req.body.note) embed.addField('📃 정보', `${req.body.note ? `${req.body.note}` : ''}`)
|
||||
await getBotReviewLogChannel().send(embed)
|
||||
return ResponseWrapper(res, { code: 200 })
|
||||
})
|
||||
|
||||
interface ApiRequest extends NextApiRequest {
|
||||
query: {
|
||||
id: string
|
||||
date: string
|
||||
}
|
||||
body: {
|
||||
note?: string
|
||||
}
|
||||
}
|
||||
|
||||
export default ApproveBotSubmit
|
||||
@ -288,6 +288,14 @@ export const ErrorText = {
|
||||
|
||||
export const ErrorMessage = ['지나가던 고양이가 선을 밟았어요..', '무언가 잘못되었어요..!', '이게 아닌데...', '어쩜 이렇게 오류가 또 나는건지?']
|
||||
|
||||
export const BotSubmissionDenyReasonPresetsName = {
|
||||
MISSING_VERIFY: '개발자 확인 불가',
|
||||
OFFLINE: '봇 오프라인',
|
||||
INVALID_CATEGORY: '올바르지 않은 카테고리',
|
||||
PRIVATE: '프라이빗 봇',
|
||||
LICENSE_VIOLATION: '오픈소스 라이선스 위반'
|
||||
}
|
||||
|
||||
export const GuildPermissions = {
|
||||
general: [
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user