From 439bad121ab5c085946875f7576e900222d0cc14 Mon Sep 17 00:00:00 2001 From: hwangsihu Date: Sat, 26 Oct 2024 12:05:50 +0900 Subject: [PATCH] Update env --- src/env.ts | 69 +----------------------------------------------------- 1 file changed, 1 insertion(+), 68 deletions(-) diff --git a/src/env.ts b/src/env.ts index 6b8218d26..57b1beade 100644 --- a/src/env.ts +++ b/src/env.ts @@ -23,59 +23,16 @@ const LavalinkNodeSchema = z.object({ }); const envSchema = z.object({ - /** - * The discord app token - */ TOKEN: z.string(), - - /** - * The client id - */ CLIENT_ID: z.string(), - - /** - * The default language - */ DEFAULT_LANGUAGE: z.string().default('EnglishUS'), - - /** - * The bot prefix - */ PREFIX: z.string().default('!'), - - /** - * The owner ids - */ OWNER_IDS: z.preprocess(val => (typeof val === 'string' ? JSON.parse(val) : val), z.string().array().optional()), - - /** - * The guild id for devlopment purposes - */ GUILD_ID: z.string().optional(), - - /** - * The Top.gg api key - */ TOPGG: z.string().optional(), - - /** - * The keep alive boolean - */ KEEP_ALIVE: z.preprocess(val => val === 'true', z.boolean().default(false)), - - /** - * The log channel id - */ LOG_CHANNEL_ID: z.string().optional(), - - /** - * The log command id - */ LOG_COMMANDS_ID: z.string().optional(), - - /** - * The bot status online | idle | dnd | invisible - */ BOT_STATUS: z.preprocess( val => { if (typeof val === 'string') { @@ -85,29 +42,14 @@ const envSchema = z.object({ }, z.enum(['online', 'idle', 'dnd', 'invisible']).default('online'), ), - - /** - * The bot activity - */ BOT_ACTIVITY: z.string().default('Lavamusic'), - - /** - * The bot activity type - */ BOT_ACTIVITY_TYPE: z.preprocess(val => { if (typeof val === 'string') { return Number.parseInt(val, 10); } return val; }, z.number().default(0)), - /** - * The database url - */ DATABASE_URL: z.string().optional(), - - /** - * Search engine - */ SEARCH_ENGINE: z.preprocess( val => { if (typeof val === 'string') { @@ -119,26 +61,17 @@ const envSchema = z.object({ .enum(['youtube', 'youtubemusic', 'soundcloud', 'spotify', 'apple', 'deezer', 'yandex', 'jiosaavn']) .default('youtube'), ), - /** - * Node in json - */ NODES: z.preprocess(val => (typeof val === 'string' ? JSON.parse(val) : val), z.array(LavalinkNodeSchema)), - /** - * Genius api - */ GENIUS_API: z.string().optional(), }); type Env = z.infer; -/** - * The environment variables - */ export const env: Env = envSchema.parse(process.env); for (const key in env) { if (!(key in env)) { - throw new Error(`Missing env variable: ${key}`); + throw new Error(`Missing env variable: ${key}. Please check the .env file and try again.`); } }