From bd05736c73015b4f36e6d50355717aa687e5deca Mon Sep 17 00:00:00 2001 From: Lea Date: Wed, 15 Mar 2023 20:24:24 +0100 Subject: [PATCH] Allow users to view their own infractions --- bot/src/bot/commands/moderation/warns.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bot/src/bot/commands/moderation/warns.ts b/bot/src/bot/commands/moderation/warns.ts index 2b96130..fb380b6 100644 --- a/bot/src/bot/commands/moderation/warns.ts +++ b/bot/src/bot/commands/moderation/warns.ts @@ -22,8 +22,6 @@ export default { syntax: '/warns; /warns @username ["export-csv"]; /warns rm [ID]', category: CommandCategory.Moderation, run: async (message: MessageCommandContext, args: string[]) => { - if (!await isModerator(message)) return message.reply(NO_MANAGER_MSG); - let infractions: Array = await dbs.INFRACTIONS.find({ server: message.serverContext._id, }); @@ -34,6 +32,8 @@ export default { }); if (!args[0]) { + if (!await isModerator(message)) return message.reply(NO_MANAGER_MSG); + // Show top most warned users let msg = `## Most warned users in ${message.serverContext.name}\n\u200b\n`; for (let inf of Array.from(userInfractions.values()).sort((a, b) => b.length - a.length).slice(0, 9)) { @@ -50,6 +50,8 @@ export default { case 'remove': case 'rm': case 'del': + if (!await isModerator(message)) return message.reply(NO_MANAGER_MSG); + let id = args[1]; if (!id) return message.reply('No infraction ID provided.'); let inf = await dbs.INFRACTIONS.findOneAndDelete({ @@ -69,6 +71,9 @@ export default { let user = await parseUserOrId(args[0]); if (!user?._id) return message.reply('I can\'t find this user.'); + + if (user._id != message.author_id && !await isModerator(message)) return message.reply(NO_MANAGER_MSG); + const infs = userInfractions.get(user._id); const userConfig = await dbs.USERS.findOne({ id: user._id });