From 0ebb78b57c0c81ea9aeeffab68819d9275774ba8 Mon Sep 17 00:00:00 2001 From: wonderlandpark Date: Thu, 25 Mar 2021 15:23:52 +0900 Subject: [PATCH] feat: added permission calculator --- pages/calculator.tsx | 122 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 pages/calculator.tsx diff --git a/pages/calculator.tsx b/pages/calculator.tsx new file mode 100644 index 0000000..ecd701d --- /dev/null +++ b/pages/calculator.tsx @@ -0,0 +1,122 @@ +import { GetServerSideProps, NextPage } from 'next' +import { useState } from 'react' +import dynamic from 'next/dynamic' +import { DiscordEnpoints, GuildPermissions } from '@utils/Constants' +import { Formik, Form } from 'formik' +import { ParsedUrlQuery } from 'node:querystring' + +const Container = dynamic(() => import('@components/Container')) +const Input = dynamic(() => import('@components/Form/Input')) + +const Calculator:NextPage = ({ query }) => { + const [ value, setValue ] = useState<{[perm: string]: boolean}>({}) + const Perm = ({ name, perm, yellow }:{ name: string, perm: number, yellow?: boolean }) => { + return
  • + +
  • + + } + return +

    봇 초대링크 생성기

    +
    권한: {Object.keys(value).filter(el => value[el]).map(el => Number(el)).reduce((prev, curr) => prev | curr, 0)} + = { Object.keys(value).filter(el => value[el]).map(el => `0x${Number(el).toString(16)}`).join(' | ') } +
    +
    +
    +

    일반 권한

    +
      + { + GuildPermissions.general.map(el => ) + } +
    + +
    +
    +

    멤버쉽 권한

    +
      + { + GuildPermissions.membership.map(el => ) + } +
    +
    +
    +

    채팅 채널 권한

    +
      + { + GuildPermissions.channel.map(el => ) + } +
    +
    +
    +

    음성 채널 권한

    +
      + { + GuildPermissions.voice.map(el => ) + } +
    +
    +
    +

    고급 권한

    +
      + { + GuildPermissions.advanced.map(el => ) + } +
    +
    +
    +
    + 노란색 = 서버에 2단계 인증 필수가 활성화되어있다면, 봇 소유자는 2단계 인증이 완료되어있어야합니다. +
    + console.log('Pong?')} initialValues={{ + id: query.id?.toString() || '', + scope: 'bot', + redirect: '' + }}> + { + ({ values, setFieldValue }) => ( +
    +
    +
    +
    봇 ID
    + 클라이언트 아이디를 입력해주세요. + +
    +
    +
    스코프 (Scope)
    + + +
    +
    +
    리다이랙트 URL
    + 초대완료 후 리다이랙트할 URL입니다. + +
    +
    + +
    + ) + } +
    +
    +} + +export const getServerSideProps: GetServerSideProps = async (ctx) => { + return { + props: { + query: ctx.query + } + } +} + +interface CalculatorProps { + query: ParsedUrlQuery +} + +export default Calculator \ No newline at end of file