Files
music_bot_v2/bot/src/utils/Config.ts
claude-bot d0dcdb1563 bot 전체 코드 품질 개선 및 버그 수정
- GuildPlayer: 타이머 레이스 컨디션 수정, 모든 타이머 정리 로직 통합 (clearAllTimers)
- GuildPlayer: 이벤트 핸들러에 try-catch 추가 (end, exception, stuck)
- GuildPlayer: start 이벤트에서 endTimer 정리, autoPlay tracks 길이 검증 추가
- RedisClient: player_seek, player_volume에 누락된 return ���가
- RedisClient: queue_remove 인덱스 검증 주석 명확화
- Handler: runCommand에 try-catch 추가하여 에러 시 사용자에게 응답
- Channel: getGuildById에 누락된 await 추가, getMemberById/getVoiceChannelById 안전한 에러 처리
- Command.d.ts: 잘못된 타입 ChatInputChatInputCommandInteraction → ChatInputCommandInteraction 수정
- join.ts: 채널 멘션 닫는 괄호 누락 수정
- shuffle.ts: 제네릭 타입 적용, 불필요한 5회 반복 제거
- import 경로 대소문자 수정 (Shuffle → shuffle) - Linux 호환
- YoutubeMusic/Spotify: 하드코딩된 IP를 환경변수로 분리
- console.log/error → Logger 통일 (YoutubeMusic, Button, channel)
- interactionCreate: 전체 try-catch 추가, silent catch에 로깅 추가
- Database: schema 경로 __dirname 기반으로 수정, 컬럼 화이트리스트 추가
- 사용하지 않는 코드 정리 (axios 의존성, 주석처리된 user 관련 코드)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-26 23:13:16 +09:00

94 lines
3.0 KiB
TypeScript

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;
},
proxyUrl: process.env.PROXY_URL?.trim() || "",
_redis: {
state: process.env.REDIS?.trim()?.toLocaleLowerCase() === "true",
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 {
state: this._redis.state,
host: this._redis.host,
port: port,
};
}
};
export const COMMANDS_PATH = join(__dirname, "..", "commands");
export const COMMAND_PATH = (commandFile: string) => join(COMMANDS_PATH, commandFile);