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