types: added and fixed

This commit is contained in:
원더 2021-01-24 22:56:12 +09:00
parent c4aef077a2
commit 3e1a020a9b
3 changed files with 15 additions and 3 deletions

View File

@ -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',

View File

@ -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`
}

View File

@ -19,7 +19,7 @@ export interface botListArgument {
export const ImageOptionsSchema: Yup.SchemaOf<ImageOptions> = Yup.object({
id: Yup.string().required(),
ext: Yup.mixed<ext>().oneOf(['webp', 'png', 'gif']).required(),
size: Yup.mixed<ImageSize>().oneOf([128, 256, 512]).required()
size: Yup.mixed<ImageSize>().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