Larger refactoring and added avoidlist

This commit is contained in:
Myx
2023-10-21 05:09:38 +02:00
parent ccf7a218fd
commit 8fd3eeae03
30 changed files with 753 additions and 213 deletions

View File

@@ -0,0 +1,20 @@
import * as fileSystem from 'fs';
import express from 'express';
import { loadAvoidList } from '../../helpers/load-avoid-list';
/**
* Adds a user to the avoid list.
* @param user - The user to add to the avoid list.
* @returns void
*/
export function AddUserToAvoidList(response: express.Response, request: express.Request) {
const avoidList = loadAvoidList();
if (avoidList.avoidUsers.includes(request.body.user)) {
response.send('User already in avoid list.');
} else {
avoidList.avoidUsers.push(request.body.user);
fileSystem.writeFileSync('avoid-list.json', JSON.stringify(avoidList, null, "\t"));
response.send('User added to avoid list.');
}
}