diff --git a/pages/addbot.tsx b/pages/addbot.tsx index 6935bd5..beb642d 100644 --- a/pages/addbot.tsx +++ b/pages/addbot.tsx @@ -368,8 +368,8 @@ const AddBot: NextPage = ({ logged, user, csrfToken, theme }) => { > ({ - label: k, - value: v, + label: v.label, + value: k, }))} handleChange={(value) => { setFieldValue( diff --git a/pages/bots/[id]/edit.tsx b/pages/bots/[id]/edit.tsx index 0c94bfb..4dbf03b 100644 --- a/pages/bots/[id]/edit.tsx +++ b/pages/bots/[id]/edit.tsx @@ -78,7 +78,6 @@ const ManageBotPage: NextPage = ({ bot, user, csrfToken, theme } ) return const isPerkAvailable = checkBotFlag(bot.flags, 'trusted') || checkBotFlag(bot.flags, 'partnered') - console.log(bot.enforcements) return ( @@ -341,8 +340,8 @@ const ManageBotPage: NextPage = ({ bot, user, csrfToken, theme } > ({ - label: k, - value: v, + label: v.label, + value: k, }))} handleChange={(value) => { setFieldValue( diff --git a/types/index.ts b/types/index.ts index f7373ba..ce349da 100644 --- a/types/index.ts +++ b/types/index.ts @@ -34,7 +34,7 @@ export interface Bot { owners: User[] | string[] } -export type BotEnforcementKeys = ValueOf +export type BotEnforcementKeys = keyof typeof botEnforcements export interface RawGuild { id: string diff --git a/utils/Constants.ts b/utils/Constants.ts index cb27d16..fbda298 100644 --- a/utils/Constants.ts +++ b/utils/Constants.ts @@ -121,10 +121,22 @@ export const botCategoryDescription = { } export const botEnforcements = { - '서버 참여가 필요한 기능이 있습니다': 'JOIN_PARTIALLY_ENFORCED', - '서버 참여 없이는 봇의 핵심 기능을 사용할 수 없습니다': 'JOIN_ENFORCED', - '유료 구매가 필요한 기능이 있습니다': 'LICENSE_PARTIALLY_ENFORCED', - '유료 구매 없이는 봇의 핵심 기능을 사용할 수 없습니다': 'LICENSE_ENFORCED', + JOIN_PARTIALLY_ENFORCED: { + label: '서버 참여가 필요한 기능이 있습니다', + description: '봇의 일부 명령어는 봇의 디스코드 서버에 참여해야 사용할 수 있습니다.', + }, + JOIN_ENFORCED: { + label: '서버 참여 없이는 봇의 핵심 기능을 사용할 수 없습니다', + description: '봇의 핵심 기능은 봇의 디스코드 서버에 참여해야 사용할 수 있습니다.', + }, + LICENSE_PARTIALLY_ENFORCED: { + label: '유료 구매가 필요한 기능이 있습니다', + description: '봇의 일부 명령어는 유료 구매가 필요합니다.', + }, + LICENSE_ENFORCED: { + label: '유료 구매 없이는 봇의 핵심 기능을 사용할 수 없습니다', + description: '유료 구매 없이는 봇의 핵심 기능을 사용할 수 없습니다.', + }, } as const export const botCategoryIcon = { diff --git a/utils/Yup.ts b/utils/Yup.ts index 2d314bf..7f73e87 100644 --- a/utils/Yup.ts +++ b/utils/Yup.ts @@ -175,7 +175,7 @@ export const AddBotSubmitSchema: Yup.SchemaOf = Yup.object({ .min(100, '봇 설명은 최소 100자여야합니다.') .max(1500, '봇 설명은 최대 1500자여야합니다.') .required('봇 설명은 필수 항목입니다.'), - enforcements: Yup.array(Yup.string().oneOf(Object.values(botEnforcements))), + enforcements: Yup.array(Yup.string().oneOf(Object.keys(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.values(botEnforcements))), + enforcements: Yup.array(Yup.string().oneOf(Object.keys(botEnforcements))), _csrf: Yup.string().required(), }