mirror of
https://github.com/Myxelium/RandomMemerBot.git
synced 2026-04-21 05:25:08 +00:00
Larger refactoring and added avoidlist
This commit is contained in:
19
client/handlers/deleteSoundFile.ts
Normal file
19
client/handlers/deleteSoundFile.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import express from 'express';
|
||||
import path from 'path';
|
||||
import * as fileSystem from 'fs';
|
||||
import { LoggerColors } from '../../helpers/logger-colors';
|
||||
|
||||
/**
|
||||
* Deletes a file from the sounds folder by filename
|
||||
*/
|
||||
export function DeleteSoundFile(response: express.Response, request: express.Request) {
|
||||
const directoryPath = path.join(__dirname, '../../sounds');
|
||||
const filePath = directoryPath + '/' + request.params.filename;
|
||||
|
||||
fileSystem.unlink(filePath, (err: any) => {
|
||||
if (err) {
|
||||
return console.log(LoggerColors.Red, 'Unable to delete file: ' + err);
|
||||
}
|
||||
response.send('File deleted successfully.');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user