Files
RandomMemerBot/client/handlers/getSoundFiles.ts
2024-05-12 19:44:36 +02:00

18 lines
654 B
TypeScript

import express from 'express';
import path from 'path';
import * as fileSystem from 'fs';
import { LoggerColors } from '../../helpers/loggerColors';
/**
* Returns a list of all sound files in the sounds directory.
* @returns string[] - An array of all sound files in the sounds directory.
*/
export function GetSoundFiles(response: express.Response) {
const directoryPath = path.join(__dirname, '../../sounds');
fileSystem.readdir(directoryPath, function (error: any, files: any[]) {
if (error) {
return console.log(LoggerColors.Red, 'Unable to scan directory: ' + error);
}
response.send(files);
});
}