update Moderation model references in modlogs cmd

merge-requests/1/merge
Matthew 2019-10-26 00:01:31 -04:00
parent 420e1f8d2e
commit 74877e8a34
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 15 additions and 4 deletions

View File

@ -19,13 +19,24 @@ export default class Modlogs extends Command {
public async run(message: Message, args: string[]) {
try {
const msg: Message = await message.channel.createMessage(`***${this.client.stores.emojis.loading} Locating modlogs...***`);
const query = await this.client.db.Moderation.find({ $or: [{ account: args.join(' ') }, { userID: args.filter((a) => a)[0].replace(/[<@!>]/g, '') }] });
const query = await this.client.db.Moderation.find({ $or: [{ username: args.join(' ') }, { userID: args.filter((a) => a)[0].replace(/[<@!>]/g, '') }] });
if (!query.length) return msg.edit(`***${this.client.stores.emojis.error} Cannot locate modlogs for ${args.join(' ')}***`);
const formatted = query.map((log) => {
const { account, moderatorID, reason, type, date } = log;
const name = type;
const value = `**Account name:** ${account}\n**Moderator:** <@${moderatorID}>\n**Reason:** ${reason}\n**Date:** ${date.toLocaleString('en-us')} EST`;
const { username, moderatorID, reason, type, date } = log;
let name: string;
if (type === 0) {
name = 'Create';
} else if (type === 1) {
name = 'Warn';
} else if (type === 2) {
name = 'Lock';
} else if (type === 3) {
name = 'Unlock';
} else if (type === 4) {
name = 'Delete';
}
const value = `**Account name:** ${username}\n**Moderator:** <@${moderatorID}>\n**Reason:** ${reason}\n**Date:** ${date.toLocaleString('en-us')} EST`;
const inline = true;
return { name, value, inline };
});