지금까지 내용 커밋
This commit is contained in:
89
bot/src/utils/Config.ts
Normal file
89
bot/src/utils/Config.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import "dotenv/config";
|
||||
import { ColorResolvable, Colors } from "discord.js";
|
||||
import { join } from "node:path";
|
||||
|
||||
export const Config = {
|
||||
debug: process.env.DEBUG?.trim()?.toLocaleLowerCase() === "true",
|
||||
dev: process.env.DEV?.trim()?.toLocaleLowerCase() === "true",
|
||||
|
||||
_prefix: process.env.PREFIX?.trim(),
|
||||
get prefix() {
|
||||
if (!this._prefix) throw new ReferenceError("PREFIX is missing");
|
||||
return this._prefix;
|
||||
},
|
||||
|
||||
_appId: process.env.APPID?.trim(),
|
||||
get appId() {
|
||||
if (!this._appId) throw new ReferenceError("APPID is missing");
|
||||
return this._appId;
|
||||
},
|
||||
|
||||
_token: process.env.TOKEN?.trim(),
|
||||
get token() {
|
||||
if (!this._token) throw new ReferenceError("TOKEN is missing");
|
||||
return this._token;
|
||||
},
|
||||
|
||||
_dbPath: process.env.DBPATH?.trim(),
|
||||
get dbPath() {
|
||||
if (!this._dbPath) throw new ReferenceError("DBPATH is missing");
|
||||
return this._dbPath;
|
||||
},
|
||||
|
||||
_guildId: process.env.GUILDID?.trim(),
|
||||
get guildId() {
|
||||
if (!this._guildId) throw new ReferenceError("GUILDID is missing");
|
||||
return this._guildId;
|
||||
},
|
||||
|
||||
_embedColor: process.env.EMBEDCOLOR?.trim(),
|
||||
get embedColor() {
|
||||
if (!this._embedColor) throw new ReferenceError("EMBEDCOLOR is missing");
|
||||
const list = Object.keys(Colors);
|
||||
if (!list.includes(this._embedColor)) throw new TypeError(`EMBEDCOLOR TYPE ERROR: ${list.join(",")}`);
|
||||
return this._embedColor as ColorResolvable;
|
||||
},
|
||||
|
||||
_lavalink: {
|
||||
host: process.env.LAVALINK_HOST?.trim(),
|
||||
port: process.env.LAVALINK_PORT?.trim(),
|
||||
pw: process.env.LAVALINK_PW?.trim(),
|
||||
},
|
||||
get lavalink() {
|
||||
if (!this._lavalink.host) throw new ReferenceError("LAVALINK_HOST is missing");
|
||||
if (!this._lavalink.port) throw new ReferenceError("LAVALINK_PORT is missing");
|
||||
if (!this._lavalink.pw) throw new ReferenceError("LAVALINK_PW is missing");
|
||||
const port = Number(this._lavalink.port!);
|
||||
if (isNaN(port)) throw new TypeError("LAVALINK_PORT must be a number");
|
||||
return {
|
||||
host: this._lavalink.host,
|
||||
port: port,
|
||||
pw: this._lavalink.pw,
|
||||
}
|
||||
},
|
||||
|
||||
_youtube_cookie: process.env.YOUTUBE_COOKIE?.trim(),
|
||||
get youtube_cookie() {
|
||||
if (!this._youtube_cookie) throw new ReferenceError("YOUTUBE_COOKIE is missing");
|
||||
if (this._youtube_cookie.startsWith('"')) this._youtube_cookie = this._youtube_cookie.slice(1,-1);
|
||||
return this._youtube_cookie;
|
||||
},
|
||||
|
||||
_redis: {
|
||||
host: process.env.REDIS_HOST?.trim(),
|
||||
port: process.env.REDIS_PORT?.trim(),
|
||||
},
|
||||
get redis() {
|
||||
if (!this._redis.host) throw new ReferenceError("REDIS_HOST is missing");
|
||||
if (!this._redis.port) throw new ReferenceError("REDIS_PORT is missing");
|
||||
const port = Number(this._redis.port!);
|
||||
if (isNaN(port)) throw new TypeError("REDIS_PORT must be a number");
|
||||
return {
|
||||
host: this._redis.host,
|
||||
port: port,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const COMMANDS_PATH = join(__dirname, "..", "commands");
|
||||
export const COMMAND_PATH = (commandFile: string) => join(COMMANDS_PATH, commandFile);
|
||||
Reference in New Issue
Block a user