From dd35b8a9d2dc03bce8f406f62ad8800a50ff848d Mon Sep 17 00:00:00 2001 From: Bsian Date: Sun, 27 Oct 2019 01:06:57 +0000 Subject: [PATCH] Created command --- src/Util.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Util.ts b/src/Util.ts index 47b4e64..bf34646 100644 --- a/src/Util.ts +++ b/src/Util.ts @@ -4,6 +4,7 @@ import childProcess from 'child_process'; import nodemailer from 'nodemailer'; import { Message, TextChannel, PrivateChannel } from 'eris'; import { outputFile } from 'fs-extra'; +import uuid from 'uuid/v4'; import { Client } from '.'; import { Command, RichEmbed } from './class'; @@ -112,4 +113,18 @@ export default class Util { tempPass += passChars[Math.floor(Math.random() * passChars.length)]; return tempPass; } + + public async createAccount(hash: string, etcPasswd: string, username: string, userID: string, emailAddress: string, moderatorID: string): Promise { + await this.exec(`useradd -m -p ${hash} -c ${etcPasswd} -s /bin/bash ${username}`); + await this.exec(`chage -d0 ${username}`); + + const log = await new this.client.db.Moderation({ + username, userID, logID: uuid(), moderatorID, reason: 'User requested account creation', type: 0, date: new Date(), + }); + const account = await new this.client.db.Account({ + username, userID, emailAddress, createdBy: moderatorID, createdAt: new Date(), locked: false, + }); + await log.save(); + await account.save(); + } }