mirror of
https://github.com/Myxelium/RandomMemerBot.git
synced 2026-04-09 08:59:39 +00:00
20 lines
701 B
TypeScript
20 lines
701 B
TypeScript
import * as fileSystem from 'fs';
|
|
import express from 'express';
|
|
import { loadAvoidList } from '../../helpers/loadAvoidList';
|
|
|
|
/**
|
|
* 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.');
|
|
}
|
|
} |