All moderation inserts use util
parent
8db1f65691
commit
08bd4645f6
|
@ -2,7 +2,7 @@
|
|||
import { promisify } from 'util';
|
||||
import childProcess from 'child_process';
|
||||
import nodemailer from 'nodemailer';
|
||||
import { Message, PrivateChannel, Member } from 'eris';
|
||||
import { Message, PrivateChannel, Member, User } from 'eris';
|
||||
import { outputFile } from 'fs-extra';
|
||||
import uuid from 'uuid/v4';
|
||||
import moment from 'moment';
|
||||
|
@ -155,7 +155,7 @@ export default class Util {
|
|||
* `3` - Unlock
|
||||
* `4` - Delete
|
||||
*/
|
||||
public async createModerationLog(user: string, moderator: Member, type: number, reason?: string, duration?: number): Promise<ModerationInterface> {
|
||||
public async createModerationLog(user: string, moderator: Member|User, type: number, reason?: string, duration?: number): Promise<ModerationInterface> {
|
||||
const moderatorID = moderator.id;
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: user }, { userID: user }] });
|
||||
if (!account) return Promise.reject(new Error(`Account ${user} not found`));
|
||||
|
@ -195,7 +195,7 @@ export default class Util {
|
|||
.setTitle(embedTitle)
|
||||
.setColor(color)
|
||||
.addField('User', `${username} | <@${userID}>`, true)
|
||||
.addField('Supervisor', `<@${moderatorID}>`, true)
|
||||
.addField('Supervisor', moderatorID === this.client.user.id ? 'SYSTEM' : `<@${moderatorID}>`, true)
|
||||
.setFooter(this.client.user.username, this.client.user.avatarURL)
|
||||
.setTimestamp();
|
||||
if (reason) embed.addField('Reason', reason || 'Not specified');
|
||||
|
|
|
@ -39,6 +39,8 @@ export default class DeleteAccount extends Command {
|
|||
const reason = args.slice(1).join(' ');
|
||||
const logInput = { username, userID, logID: uuid(), moderatorID: message.author.id, type: 4, date: new Date(), reason: null };
|
||||
if (reason) logInput.reason = reason;
|
||||
await this.client.util.createModerationLog(args[0], message.member, 4, reason);
|
||||
/*
|
||||
const log = await new this.client.db.Moderation(logInput);
|
||||
await log.save();
|
||||
|
||||
|
@ -56,6 +58,7 @@ export default class DeleteAccount extends Command {
|
|||
// @ts-ignore
|
||||
user.createMessage({ embed }).catch();
|
||||
});
|
||||
*/
|
||||
|
||||
this.client.util.transport.sendMail({
|
||||
to: account.emailAddress,
|
||||
|
|
|
@ -29,13 +29,20 @@ export default class Lock extends Command {
|
|||
const lockLength = args[1].match(/[a-z]+|[^a-z]+/gi);
|
||||
// @ts-ignore
|
||||
const momentMilliseconds = moment.duration(Number(lockLength[0]), lockLength[1]).asMilliseconds();
|
||||
/*
|
||||
expiry.setMilliseconds(momentMilliseconds);
|
||||
let processed: boolean = false;
|
||||
if (!momentMilliseconds) processed = true;
|
||||
*/
|
||||
|
||||
this.client.signale.debug(lockLength);
|
||||
this.client.signale.debug(expiry);
|
||||
this.client.signale.debug(momentMilliseconds);
|
||||
const reason = momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' ');
|
||||
|
||||
await this.client.util.createModerationLog(account.userID, message.member, 2, reason, momentMilliseconds);
|
||||
|
||||
/*
|
||||
const moderation = new this.client.db.Moderation({
|
||||
username: account.username,
|
||||
userID: account.userID,
|
||||
|
@ -67,6 +74,7 @@ export default class Lock extends Command {
|
|||
});
|
||||
// @ts-ignore
|
||||
this.client.createMessage('580950455581147146', { embed });
|
||||
*/
|
||||
|
||||
this.client.util.transport.sendMail({
|
||||
to: account.emailAddress,
|
||||
|
|
|
@ -23,6 +23,8 @@ export default class Unlock extends Command {
|
|||
await this.client.util.exec(`unlock ${account.username}`);
|
||||
await account.updateOne({ locked: false });
|
||||
|
||||
await this.client.util.createModerationLog(account.userID, message.member, 3, args.slice(1).join(' '));
|
||||
/*
|
||||
const moderation = new this.client.db.Moderation({
|
||||
username: account.username,
|
||||
userID: account.userID,
|
||||
|
@ -33,7 +35,11 @@ export default class Unlock extends Command {
|
|||
date: new Date(),
|
||||
});
|
||||
await moderation.save();
|
||||
*/
|
||||
|
||||
edit.edit(`***${this.client.stores.emojis.success} Account ${account.username} has been unlocked by Supervisor ${message.author.username}#${message.author.discriminator}.***`);
|
||||
|
||||
/*
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle('Account Infraction | Unlock');
|
||||
embed.setColor(15158332);
|
||||
|
@ -49,6 +55,7 @@ export default class Unlock extends Command {
|
|||
});
|
||||
// @ts-ignore
|
||||
this.client.createMessage('580950455581147146', { embed });
|
||||
*/
|
||||
} catch (error) {
|
||||
await this.client.util.handleError(error, message, this);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ export default function checkLock(client: Client) {
|
|||
await client.util.exec(`unlock ${account.username}`);
|
||||
await moderation.updateOne({ 'expiration.processed': true });
|
||||
await account.updateOne({ locked: false });
|
||||
await client.util.createModerationLog(account.userID, client.user, 3, 'Auto');
|
||||
/*
|
||||
const mod = new client.db.Moderation({
|
||||
username: account.username,
|
||||
userID: account.userID,
|
||||
|
@ -39,6 +41,7 @@ export default function checkLock(client: Client) {
|
|||
});
|
||||
// @ts-ignore
|
||||
client.createMessage('580950455581147146', { embed });
|
||||
*/
|
||||
client.signale.complete(`Unlocked account ${account.username} | Queue date at ${moderation.expiration.date.toLocaleString('en-us')}`);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue