From 58882ad5cadff9d645b18f231328c1afbd9bfe97 Mon Sep 17 00:00:00 2001 From: Junseo Park Date: Thu, 25 Feb 2021 11:12:33 +0900 Subject: [PATCH] chore: added status widget --- utils/Constants.ts | 10 ++++++++++ utils/Yup.ts | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/utils/Constants.ts b/utils/Constants.ts index 023febf..b868f4e 100644 --- a/utils/Constants.ts +++ b/utils/Constants.ts @@ -139,6 +139,16 @@ export const BotBadgeType = (data: Bot) => { votes: { label: '하트', status: `${formatNumber(data.votes)}` + }, + status: { + label: '상태', + status: Status[data.status]?.text || '알 수 없음', + color: { + online: '34d399', + idle: 'fcd34d', + dnd: 'ef4444', + streaming: '8b5cf6' + }[data.status] || '6b7280' } } } diff --git a/utils/Yup.ts b/utils/Yup.ts index d7eaca6..a9bfe4e 100644 --- a/utils/Yup.ts +++ b/utils/Yup.ts @@ -41,7 +41,7 @@ type ImageSize = '128' | '256' | '512' export const WidgetOptionsSchema: Yup.SchemaOf = Yup.object({ id: Yup.string().required(), ext: Yup.mixed().oneOf(['svg']).required(), - type: Yup.mixed().oneOf(['votes', 'servers']).required(), + type: Yup.mixed().oneOf(['votes', 'servers', 'status']).required(), scale: Yup.number().positive().min(0.5).max(3).required(), style: Yup.mixed<'flat'|'classic'>().oneOf(['flat', 'classic']).default('flat') }) @@ -54,7 +54,7 @@ interface WidgetOptions { style: 'flat' | 'classic' } -type widgetType = 'votes' | 'servers' +type widgetType = 'votes' | 'servers' | 'status' type widgetExt = 'svg' export const PageCount = Yup.number().integer().positive().required()