add global blacklist reasons
This commit is contained in:
parent
d7e52b1756
commit
45a9021832
4 changed files with 25 additions and 4 deletions
|
@ -29,7 +29,7 @@ app.get('/stats/global_blacklist', async (req: Request, res: Response) => {
|
|||
|
||||
res.send({
|
||||
total: users.length,
|
||||
blacklist: users.map(u => ({ id: u.id?.toUpperCase() })),
|
||||
blacklist: users.map(u => ({ id: u.id?.toUpperCase(), reason: u.blacklistReason || null })),
|
||||
});
|
||||
} catch(e) {
|
||||
console.error(''+e);
|
||||
|
|
|
@ -38,6 +38,7 @@ const SUBCOMMANDS: string[] = [
|
|||
'userinfo',
|
||||
'blacklist',
|
||||
'unblacklist',
|
||||
'blacklistreason',
|
||||
'ignore',
|
||||
'unignore',
|
||||
];
|
||||
|
@ -221,6 +222,22 @@ export default {
|
|||
break;
|
||||
}
|
||||
|
||||
case 'blacklistreason': {
|
||||
const target = await parseUserOrId(args.shift() || '');
|
||||
if (!target) return message.reply('Specified user could not be found.');
|
||||
|
||||
await dbs.USERS.update({
|
||||
id: target._id,
|
||||
}, {
|
||||
$setOnInsert: { id: target._id },
|
||||
$set: { blacklistReason: args.join(' ') || undefined }
|
||||
}, { upsert: true });
|
||||
|
||||
await message.reply(`User update stored.`);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'ignore': {
|
||||
const target = await parseUserOrId(args.shift() || '');
|
||||
if (!target) return message.reply('Specified user could not be found.');
|
||||
|
|
|
@ -12,7 +12,8 @@ import CommandCategory from "../../struct/commands/CommandCategory";
|
|||
|
||||
Day.extend(RelativeTime);
|
||||
|
||||
const GLOBAL_BLACKLIST_TEXT = `> :warning: This user has been flagged and is globally blacklisted. [Learn more.](https://github.com/janderedev/automod/wiki/Global-Blacklist)\n\n`;
|
||||
const GLOBAL_BLACKLIST_TEXT = (reason?: string) => `> :warning: This user has been flagged and is globally blacklisted. [Learn more.](https://github.com/janderedev/automod/wiki/Global-Blacklist)`
|
||||
+ `${reason ? `\nReason: "${reason}"` : ''}\n\n`;
|
||||
|
||||
export default {
|
||||
name: 'warns',
|
||||
|
@ -72,12 +73,12 @@ export default {
|
|||
const userConfig = await dbs.USERS.findOne({ id: user._id });
|
||||
|
||||
if (!infs) return message.reply(`There are no infractions stored for \`${await fetchUsername(user._id)}\`.`
|
||||
+ (userConfig?.globalBlacklist ? '\n' + GLOBAL_BLACKLIST_TEXT : ''), false);
|
||||
+ (userConfig?.globalBlacklist ? '\n' + GLOBAL_BLACKLIST_TEXT(userConfig.blacklistReason) : ''), false);
|
||||
else {
|
||||
let msg = `## ${infs.length} infractions stored for ${await fetchUsername(user._id)}\n`;
|
||||
|
||||
if (userConfig?.globalBlacklist) {
|
||||
msg += GLOBAL_BLACKLIST_TEXT;
|
||||
msg += GLOBAL_BLACKLIST_TEXT(userConfig.blacklistReason);
|
||||
} else msg += '\u200b\n';
|
||||
|
||||
let attachSpreadsheet = false;
|
||||
|
|
|
@ -8,4 +8,7 @@ export default class DbUser {
|
|||
|
||||
// Whether the user is globally marked as bad actor
|
||||
globalBlacklist?: boolean;
|
||||
|
||||
// Optional reason why the user is blacklisted
|
||||
blacklistReason?: string;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue