diff --git a/types/index.ts b/types/index.ts index 7f02766..6ba524d 100644 --- a/types/index.ts +++ b/types/index.ts @@ -107,6 +107,12 @@ export interface ImageOptions { format?: ImageFormat size?: ImageSize } + +export interface KoreanbotsImageOptions { + format?: 'webp' | 'png' | 'gif' + size?: 128 | 256 | 512 +} + export enum DiscordImageType { EMOJI = 'emoji', GUILD = 'guild', diff --git a/utils/Constants.ts b/utils/Constants.ts index d0b849e..e60fc62 100644 --- a/utils/Constants.ts +++ b/utils/Constants.ts @@ -1,4 +1,4 @@ -import { ImageOptions } from '@types' +import { ImageOptions, KoreanbotsImageOptions } from '@types' import { makeImageURL } from './Tools' export const Status = { @@ -104,6 +104,12 @@ export const DiscordEnpoints = { } } +export const KoreanbotsEndPoints = { + CDN: class CDN { + static avatar (id: string, options: KoreanbotsImageOptions) { return makeImageURL(`/api/image/discord/avatars/${id}`, options) } + } +} + export const Oauth = { discord: (clientID: string, scope: string) => `https://discord.com/oauth2/authorize?client_id=${clientID}&scope=${scope}&permissions=0&response_type=code&redirect_uri=${process.env.KOREANBOTS_URL}/api/auth/discord/callback&prompt=none` } diff --git a/utils/Yup.ts b/utils/Yup.ts index d418175..5d7b662 100644 --- a/utils/Yup.ts +++ b/utils/Yup.ts @@ -19,7 +19,7 @@ export interface botListArgument { export const ImageOptionsSchema: Yup.SchemaOf = Yup.object({ id: Yup.string().required(), ext: Yup.mixed().oneOf(['webp', 'png', 'gif']).required(), - size: Yup.mixed().oneOf([128, 256, 512]).required() + size: Yup.mixed().oneOf(['128', '256', '512']).required() }) interface ImageOptions { @@ -29,7 +29,7 @@ interface ImageOptions { } type ext = 'webp' | 'png' | 'gif' -type ImageSize = 128 | 256 | 512 +type ImageSize = '128' | '256' | '512' export default Yup \ No newline at end of file