mirror of
https://github.com/Myxelium/RandomMemerBot.git
synced 2026-04-13 18:40:36 +00:00
Larger refactoring and added avoidlist
This commit is contained in:
20
client/handlers/addUserToAvoidList.ts
Normal file
20
client/handlers/addUserToAvoidList.ts
Normal 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.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user