Fix startup crash from a circular DATA_DIR import.
Soundboard loaded main before DATA_DIR was initialized, so path.join got undefined and the container looped. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
5
src/config.ts
Normal file
5
src/config.ts
Normal file
@@ -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";
|
||||||
@@ -8,9 +8,9 @@ import { handleSoundboardButton } from "./soundboard";
|
|||||||
import { AudioPlayerStatus, AudioPlayerState, createAudioPlayer } from '@discordjs/voice';
|
import { AudioPlayerStatus, AudioPlayerState, createAudioPlayer } from '@discordjs/voice';
|
||||||
import { updatePlayer } from './playback';
|
import { updatePlayer } from './playback';
|
||||||
import SpotifyWebApi from 'spotify-web-api-node';
|
import SpotifyWebApi from 'spotify-web-api-node';
|
||||||
|
import { DATA_DIR, HISTORY_DIR_PATH } from './config';
|
||||||
|
|
||||||
export const DATA_DIR = "./data";
|
export { DATA_DIR, HISTORY_DIR_PATH };
|
||||||
export const HISTORY_DIR_PATH = process.env.HISTORY_DIR_PATH ?? "./history";
|
|
||||||
|
|
||||||
// AUDIO
|
// AUDIO
|
||||||
export const player = createAudioPlayer();
|
export const player = createAudioPlayer();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
MessageFlags,
|
MessageFlags,
|
||||||
parseEmoji,
|
parseEmoji,
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
import { DATA_DIR } from "./main";
|
import { DATA_DIR } from "./config";
|
||||||
import { connectToChannelByInteraction } from "./util/helpers";
|
import { connectToChannelByInteraction } from "./util/helpers";
|
||||||
import { playSoundboardFile } from "./playback";
|
import { playSoundboardFile } from "./playback";
|
||||||
import { PRIMARY_COLOR } from "./theme";
|
import { PRIMARY_COLOR } from "./theme";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { spawn } from "node:child_process";
|
import { spawn } from "node:child_process";
|
||||||
import fs from "node:fs";
|
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';
|
import ytSearch from 'yt-search';
|
||||||
|
|
||||||
function ytDlpBin() {
|
function ytDlpBin() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import fs from "node:fs";
|
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) {
|
export async function add_to_history(data: HistoryObject) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user