warns can now be deleted ig

This commit is contained in:
JandereDev 2021-10-13 21:38:22 +02:00
parent 2b851c813c
commit ceef16e01f
No known key found for this signature in database
GPG key ID: 5D5E18ACB990F57A

View file

@ -16,7 +16,7 @@ export default {
name: 'warns', name: 'warns',
aliases: [ 'warnings', 'infractions', 'infraction' ], aliases: [ 'warnings', 'infractions', 'infraction' ],
description: 'Show all user infractions', description: 'Show all user infractions',
syntax: '/warns; /warns @username; /warns @username export-csv', syntax: '/warns; /warns @username ["export-csv"]; /warns rm [ID]',
run: async (message: Message, args: string[]) => { run: async (message: Message, args: string[]) => {
if (!await isModerator(message.member!)) return message.reply(NO_MANAGER_MSG); if (!await isModerator(message.member!)) return message.reply(NO_MANAGER_MSG);
@ -42,6 +42,27 @@ export default {
message.reply(msg.substr(0, 1999)); message.reply(msg.substr(0, 1999));
} else { } else {
switch(args[0]?.toLowerCase()) {
case 'delete':
case 'remove':
case 'rm':
case 'del':
let id = args[1];
if (!id) return message.reply('No infraction ID provided.');
let inf: Infraction|null = await client.db.get('infractions').findOneAndDelete({
_id: { $eq: id.toUpperCase() },
server: message.channel?.server_id
});
if (!inf) return message.reply('I can\'t find that ID.');
message.reply(`## Infraction deleted\n\u200b\n`
+ `ID: \`${inf._id}\`\n`
+ `Reason: \`${inf.reason}\` `
+ `(${inf.type == InfractionType.Manual ? await fetchUsername(inf.createdBy ?? '') : 'System'})\n`
+ `Created ${Day(inf.date).fromNow()}`);
break;
default:
let user = await parseUser(args[0]); let user = await parseUser(args[0]);
if (!user) return message.reply('Unknown user'); if (!user) return message.reply('Unknown user');
@ -104,6 +125,8 @@ export default {
} }
} else message.reply(msg); } else message.reply(msg);
} }
break;
}
} }
} }
} as Command; } as Command;