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:
20
client/handlers/deleteUserFromAvoidList.ts
Normal file
20
client/handlers/deleteUserFromAvoidList.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import express from 'express';
|
||||
import fs from 'fs';
|
||||
import { loadAvoidList } from '../../helpers/load-avoid-list';
|
||||
|
||||
/**
|
||||
* Removes a user from the avoid list.
|
||||
* @param user - The user to remove from the avoid list.
|
||||
* @returns void
|
||||
*/
|
||||
export function DeleteUserFromAvoidList(response: express.Response, request: express.Request) {
|
||||
const avoidList = loadAvoidList();
|
||||
|
||||
if (avoidList.avoidUsers.includes(request.params.user)) {
|
||||
avoidList.avoidUsers = avoidList.avoidUsers.filter(user => user !== request.params.user);
|
||||
fs.writeFileSync('avoid-list.json', JSON.stringify(avoidList, null, "\t"));
|
||||
response.send('User removed from avoid list.');
|
||||
} else {
|
||||
response.send('User not in avoid list.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user