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({
|
res.send({
|
||||||
total: users.length,
|
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) {
|
} catch(e) {
|
||||||
console.error(''+e);
|
console.error(''+e);
|
||||||
|
|
|
@ -38,6 +38,7 @@ const SUBCOMMANDS: string[] = [
|
||||||
'userinfo',
|
'userinfo',
|
||||||
'blacklist',
|
'blacklist',
|
||||||
'unblacklist',
|
'unblacklist',
|
||||||
|
'blacklistreason',
|
||||||
'ignore',
|
'ignore',
|
||||||
'unignore',
|
'unignore',
|
||||||
];
|
];
|
||||||
|
@ -221,6 +222,22 @@ export default {
|
||||||
break;
|
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': {
|
case 'ignore': {
|
||||||
const target = await parseUserOrId(args.shift() || '');
|
const target = await parseUserOrId(args.shift() || '');
|
||||||
if (!target) return message.reply('Specified user could not be found.');
|
if (!target) return message.reply('Specified user could not be found.');
|
||||||
|
|
|
@ -12,7 +12,8 @@ import CommandCategory from "../../struct/commands/CommandCategory";
|
||||||
|
|
||||||
Day.extend(RelativeTime);
|
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 {
|
export default {
|
||||||
name: 'warns',
|
name: 'warns',
|
||||||
|
@ -72,12 +73,12 @@ export default {
|
||||||
const userConfig = await dbs.USERS.findOne({ id: user._id });
|
const userConfig = await dbs.USERS.findOne({ id: user._id });
|
||||||
|
|
||||||
if (!infs) return message.reply(`There are no infractions stored for \`${await fetchUsername(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 {
|
else {
|
||||||
let msg = `## ${infs.length} infractions stored for ${await fetchUsername(user._id)}\n`;
|
let msg = `## ${infs.length} infractions stored for ${await fetchUsername(user._id)}\n`;
|
||||||
|
|
||||||
if (userConfig?.globalBlacklist) {
|
if (userConfig?.globalBlacklist) {
|
||||||
msg += GLOBAL_BLACKLIST_TEXT;
|
msg += GLOBAL_BLACKLIST_TEXT(userConfig.blacklistReason);
|
||||||
} else msg += '\u200b\n';
|
} else msg += '\u200b\n';
|
||||||
|
|
||||||
let attachSpreadsheet = false;
|
let attachSpreadsheet = false;
|
||||||
|
|
|
@ -8,4 +8,7 @@ export default class DbUser {
|
||||||
|
|
||||||
// Whether the user is globally marked as bad actor
|
// Whether the user is globally marked as bad actor
|
||||||
globalBlacklist?: boolean;
|
globalBlacklist?: boolean;
|
||||||
|
|
||||||
|
// Optional reason why the user is blacklisted
|
||||||
|
blacklistReason?: string;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue