mirror of
https://github.com/Myxelium/RandomMemerBot.git
synced 2026-07-08 22:15:09 +00:00
Larger refactoring and added avoidlist
This commit is contained in:
11
helpers/get-random-sound-file-path.ts
Normal file
11
helpers/get-random-sound-file-path.ts
Normal 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)];
|
||||
}
|
||||
Reference in New Issue
Block a user