Files
RandomMemerBot/client/handlers/getSoundFiles.ts
2023-10-21 05:09:38 +02:00

18 lines
655 B
TypeScript

import express from 'express';
import path from 'path';
import * as fileSystem from 'fs';
import { LoggerColors } from '../../helpers/logger-colors';
/**
* 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);
});
}