mirror of
https://github.com/koreanbots/core.git
synced 2025-12-16 14:30:22 +00:00
Compare commits
6 Commits
90b62e41b6
...
c24c979931
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c24c979931 | ||
|
|
fd5f3c537e | ||
|
|
f4d388cca7 | ||
|
|
c9df8d01e3 | ||
|
|
5cdb0f5dd1 | ||
|
|
7a983d7d96 |
@ -368,8 +368,8 @@ const AddBot: NextPage<AddBotProps> = ({ logged, user, csrfToken, theme }) => {
|
||||
>
|
||||
<Selects
|
||||
options={Object.entries(botEnforcements).map(([k, v]) => ({
|
||||
label: v.label,
|
||||
value: k,
|
||||
label: k,
|
||||
value: v,
|
||||
}))}
|
||||
handleChange={(value) => {
|
||||
setFieldValue(
|
||||
|
||||
@ -78,6 +78,7 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
|
||||
)
|
||||
return <Forbidden />
|
||||
const isPerkAvailable = checkBotFlag(bot.flags, 'trusted') || checkBotFlag(bot.flags, 'partnered')
|
||||
console.log(bot.enforcements)
|
||||
return (
|
||||
<Container paddingTop className='pb-10 pt-5'>
|
||||
<NextSeo title={`${bot.name} 수정하기`} description='봇의 정보를 수정합니다.' />
|
||||
@ -340,8 +341,8 @@ const ManageBotPage: NextPage<ManageBotProps> = ({ bot, user, csrfToken, theme }
|
||||
>
|
||||
<Selects
|
||||
options={Object.entries(botEnforcements).map(([k, v]) => ({
|
||||
label: v.label,
|
||||
value: k,
|
||||
label: k,
|
||||
value: v,
|
||||
}))}
|
||||
handleChange={(value) => {
|
||||
setFieldValue(
|
||||
|
||||
@ -9,9 +9,9 @@ import Tooltip from 'rc-tooltip'
|
||||
|
||||
import { SnowflakeUtil } from 'discord.js'
|
||||
import { ParsedUrlQuery } from 'querystring'
|
||||
import { Bot, ResponseProps, Theme, User } from '@types'
|
||||
import { Bot, BotEnforcementKeys, ResponseProps, Theme, User } from '@types'
|
||||
|
||||
import { botEnforcements, git, KoreanbotsEndPoints, reportCats, Status } from '@utils/Constants'
|
||||
import { git, KoreanbotsEndPoints, reportCats, Status } from '@utils/Constants'
|
||||
import { get } from '@utils/Query'
|
||||
import Day from '@utils/Day'
|
||||
import { ReportSchema } from '@utils/Yup'
|
||||
@ -120,9 +120,16 @@ const Bots: NextPage<BotsProps> = ({ data, desc, date, user, theme, csrfToken })
|
||||
<Message type='warning'>
|
||||
<h2 className='text-lg font-extrabold'>이 봇은 기능에 제한을 두고 있습니다.</h2>
|
||||
<p>
|
||||
{data.enforcements.map((i) => (
|
||||
<li key={i}>{botEnforcements[i].description}</li>
|
||||
))}
|
||||
{Object.entries({
|
||||
JOIN_ENFORCED:
|
||||
'봇의 핵심 기능은 봇의 디스코드 서버에 참여해야 사용할 수 있습니다.',
|
||||
JOIN_PARTIALLY_ENFORCED:
|
||||
'봇의 일부 명령어는 봇의 디스코드 서버에 참여해야 사용할 수 있습니다.',
|
||||
})
|
||||
.filter((el) => data.enforcements.includes(el[0] as BotEnforcementKeys))
|
||||
.map(([k, v]) => (
|
||||
<li key={k}>{v}</li>
|
||||
))}
|
||||
</p>
|
||||
</Message>
|
||||
) : (
|
||||
|
||||
2
types/global.d.ts
vendored
2
types/global.d.ts
vendored
@ -2,7 +2,6 @@
|
||||
import * as Yup from 'yup'
|
||||
import { Client } from 'discord.js'
|
||||
import NotificationManager from '@utils/NotificationManager'
|
||||
import { CacheManager } from '@utils/Query'
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@ -15,7 +14,6 @@ declare global {
|
||||
var kodl: Client
|
||||
var serverlist: Client
|
||||
var notification: NotificationManager
|
||||
var get: CacheManager
|
||||
interface Navigator {
|
||||
standalone?: boolean
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ export interface Bot {
|
||||
owners: User[] | string[]
|
||||
}
|
||||
|
||||
export type BotEnforcementKeys = keyof typeof botEnforcements
|
||||
export type BotEnforcementKeys = ValueOf<typeof botEnforcements>
|
||||
|
||||
export interface RawGuild {
|
||||
id: string
|
||||
|
||||
@ -121,22 +121,10 @@ export const botCategoryDescription = {
|
||||
}
|
||||
|
||||
export const botEnforcements = {
|
||||
JOIN_PARTIALLY_ENFORCED: {
|
||||
label: '서버 참여가 필요한 기능이 있습니다',
|
||||
description: '봇의 일부 명령어는 봇의 디스코드 서버에 참여해야 사용할 수 있습니다.',
|
||||
},
|
||||
JOIN_ENFORCED: {
|
||||
label: '서버 참여 없이는 봇의 핵심 기능을 사용할 수 없습니다',
|
||||
description: '봇의 핵심 기능은 봇의 디스코드 서버에 참여해야 사용할 수 있습니다.',
|
||||
},
|
||||
LICENSE_PARTIALLY_ENFORCED: {
|
||||
label: '유료 구매가 필요한 기능이 있습니다',
|
||||
description: '봇의 일부 명령어는 유료 구매가 필요합니다.',
|
||||
},
|
||||
LICENSE_ENFORCED: {
|
||||
label: '유료 구매 없이는 봇의 핵심 기능을 사용할 수 없습니다',
|
||||
description: '유료 구매 없이는 봇의 핵심 기능을 사용할 수 없습니다.',
|
||||
},
|
||||
'서버 참여가 필요한 기능이 있습니다': 'JOIN_PARTIALLY_ENFORCED',
|
||||
'서버 참여 없이는 봇의 핵심 기능을 사용할 수 없습니다': 'JOIN_ENFORCED',
|
||||
'유료 구매가 필요한 기능이 있습니다': 'LICENSE_PARTIALLY_ENFORCED',
|
||||
'유료 구매 없이는 봇의 핵심 기능을 사용할 수 없습니다': 'LICENSE_ENFORCED',
|
||||
} as const
|
||||
|
||||
export const botCategoryIcon = {
|
||||
|
||||
@ -103,7 +103,7 @@ async function getBot(id: string, topLevel = true): Promise<Bot> {
|
||||
res.owners = JSON.parse(res.owners)
|
||||
res.banner = res.banner ? camoUrl(res.banner) : null
|
||||
res.bg = res.bg ? camoUrl(res.bg) : null
|
||||
res.enforcements = JSON.parse(res.enforcements ?? '[]')
|
||||
res.enforcements = JSON.parse(res.enforcements ?? '"[]"')
|
||||
if (discordBot.flags.bitfield & UserFlags.BotHTTPInteractions) {
|
||||
res.status = 'online'
|
||||
} else if (botMember) {
|
||||
@ -465,7 +465,7 @@ async function getBotSubmit(id: string, date: number): Promise<SubmittedBot> {
|
||||
.where({ id, date })
|
||||
if (res.length === 0) return null
|
||||
res[0].category = JSON.parse(res[0].category)
|
||||
res[0].enforcements = JSON.parse(res[0].enforcements || '[]')
|
||||
res[0].enforcements = JSON.parse(res[0].enforcements || '"[]"')
|
||||
res[0].owner = await get.user.load(res[0].owner)
|
||||
return res[0]
|
||||
}
|
||||
@ -1208,7 +1208,7 @@ async function viewBot(id: string) {
|
||||
await Bots.findByIdAndUpdate(id, { $push: { viewMetrix: { count: 0 } } }, { upsert: true })
|
||||
}
|
||||
|
||||
const _get = {
|
||||
export const get = {
|
||||
discord: {
|
||||
user: new DataLoader(
|
||||
async (ids: string[]) =>
|
||||
@ -1423,14 +1423,6 @@ const _get = {
|
||||
},
|
||||
}
|
||||
|
||||
export type CacheManager = typeof _get
|
||||
|
||||
if (!global.get) {
|
||||
global.get = _get
|
||||
}
|
||||
|
||||
export const get = global.get
|
||||
|
||||
export const update = {
|
||||
assignToken,
|
||||
resetBotToken,
|
||||
|
||||
@ -175,7 +175,7 @@ export const AddBotSubmitSchema: Yup.SchemaOf<AddBotSubmit> = Yup.object({
|
||||
.min(100, '봇 설명은 최소 100자여야합니다.')
|
||||
.max(1500, '봇 설명은 최대 1500자여야합니다.')
|
||||
.required('봇 설명은 필수 항목입니다.'),
|
||||
enforcements: Yup.array(Yup.string().oneOf(Object.keys(botEnforcements))),
|
||||
enforcements: Yup.array(Yup.string().oneOf(Object.values(botEnforcements))),
|
||||
_csrf: Yup.string().required(),
|
||||
_captcha: Yup.string().required(),
|
||||
})
|
||||
@ -306,7 +306,7 @@ export function getManageBotSchema(perkAvailable = false) {
|
||||
.min(100, '봇 설명은 최소 100자여야합니다.')
|
||||
.max(1500, '봇 설명은 최대 1500자여야합니다.')
|
||||
.required('봇 설명은 필수 항목입니다.'),
|
||||
enforcements: Yup.array(Yup.string().oneOf(Object.keys(botEnforcements))),
|
||||
enforcements: Yup.array(Yup.string().oneOf(Object.values(botEnforcements))),
|
||||
_csrf: Yup.string().required(),
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user