diff --git a/src/config.ts b/src/config.ts new file mode 100644 index 0000000..068bf10 --- /dev/null +++ b/src/config.ts @@ -0,0 +1,5 @@ +import dotenv from "dotenv"; +dotenv.config(); + +export const DATA_DIR = process.env.DATA_DIR ?? "./data"; +export const HISTORY_DIR_PATH = process.env.HISTORY_DIR_PATH ?? "./history"; diff --git a/src/main.ts b/src/main.ts index 25bc100..ef81fdb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,9 +8,9 @@ import { handleSoundboardButton } from "./soundboard"; import { AudioPlayerStatus, AudioPlayerState, createAudioPlayer } from '@discordjs/voice'; import { updatePlayer } from './playback'; import SpotifyWebApi from 'spotify-web-api-node'; +import { DATA_DIR, HISTORY_DIR_PATH } from './config'; -export const DATA_DIR = "./data"; -export const HISTORY_DIR_PATH = process.env.HISTORY_DIR_PATH ?? "./history"; +export { DATA_DIR, HISTORY_DIR_PATH }; // AUDIO export const player = createAudioPlayer(); diff --git a/src/soundboard.ts b/src/soundboard.ts index dd4bb38..6fec8e7 100644 --- a/src/soundboard.ts +++ b/src/soundboard.ts @@ -14,7 +14,7 @@ import { MessageFlags, parseEmoji, } from "discord.js"; -import { DATA_DIR } from "./main"; +import { DATA_DIR } from "./config"; import { connectToChannelByInteraction } from "./util/helpers"; import { playSoundboardFile } from "./playback"; import { PRIMARY_COLOR } from "./theme"; diff --git a/src/util/downloader.ts b/src/util/downloader.ts index f0969fd..17620b6 100644 --- a/src/util/downloader.ts +++ b/src/util/downloader.ts @@ -1,6 +1,7 @@ import { spawn } from "node:child_process"; import fs from "node:fs"; -import { DATA_DIR, spotify } from "../main"; +import { DATA_DIR } from "../config"; +import { spotify } from "../main"; import ytSearch from 'yt-search'; function ytDlpBin() { diff --git a/src/util/history.ts b/src/util/history.ts index b28ecef..bd8be26 100644 --- a/src/util/history.ts +++ b/src/util/history.ts @@ -1,6 +1,6 @@ import path from "node:path"; import fs from "node:fs"; -import { HISTORY_DIR_PATH } from "../main"; +import { HISTORY_DIR_PATH } from "../config"; export async function add_to_history(data: HistoryObject) { try {