Add database

This commit is contained in:
Myx
2024-05-12 19:44:36 +02:00
parent 99b1ee39df
commit 1d6f9c3fb2
23 changed files with 112 additions and 67 deletions

View File

@@ -0,0 +1,11 @@
import * as fileSystem from 'fs';
export const soundsDirectory = './sounds/';
/**
* Returns a random sound file from the sounds directory.
* @returns string - The path to a random sound file.
*/
export function getRandomSoundFilePath(): string {
const allSoundFilesAsArray = fileSystem.readdirSync(soundsDirectory).filter(file => file.endsWith('.mp3'));
return soundsDirectory + allSoundFilesAsArray[Math.floor(Math.random() * allSoundFilesAsArray.length)];
}