1
0
Fork 0

qol changes for Util.ts

pull/1/head
Matthew 2024-01-06 19:10:42 -05:00
parent 77e50b61c5
commit 276467519f
Signed by: matthew
SSH Key Fingerprint: SHA256:piIXekA9q1p0ZGi4ogFbNY1embip5Ytbi3v8AZ8UYq4
1 changed files with 10 additions and 12 deletions

View File

@ -2,18 +2,18 @@
/* eslint-disable no-await-in-loop */ /* eslint-disable no-await-in-loop */
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
import axios from 'axios'; import axios from 'axios';
import { randomBytes } from 'crypto'; import {randomBytes} from 'crypto';
import childProcess from 'child_process'; import childProcess from 'child_process';
import nodemailer from 'nodemailer'; import nodemailer from 'nodemailer';
import { Message, DMChannel, User, MessageEmbed, ColorResolvable, TextChannel } from 'discord.js'; import {ColorResolvable, DMChannel, Message, MessageEmbed, TextChannel, User} from 'discord.js';
import { v4 as uuid } from 'uuid'; import {v4 as uuid} from 'uuid';
import moment from 'moment'; import moment from 'moment';
import fs from 'fs'; import fs from 'fs';
import hastebin from 'hastebin-gen'; import hastebin from 'hastebin-gen';
import { getUserByUid } from '../functions'; import {getUserByUid} from '../functions';
import { AccountUtil, Client, Command, PaginationEmbed } from '.'; import {AccountUtil, Client, Command, PaginationEmbed} from '.';
import { ModerationInterface, AccountInterface } from '../models'; import {AccountInterface, ModerationInterface} from '../models';
import { Certificate } from '../../types/x509'; import {Certificate} from '../../types/x509';
export default class Util { export default class Util {
public client: Client; public client: Client;
@ -46,7 +46,7 @@ export default class Util {
cmd.stdout.on('data', writeFunction); cmd.stdout.on('data', writeFunction);
cmd.stderr.on('data', writeFunction); cmd.stderr.on('data', writeFunction);
cmd.on('error', writeFunction); cmd.on('error', writeFunction);
cmd.once('close', (code, signal) => { cmd.once('close', (code) => {
cmd.stdout.off('data', writeFunction); cmd.stdout.off('data', writeFunction);
cmd.stderr.off('data', writeFunction); cmd.stderr.off('data', writeFunction);
cmd.off('error', writeFunction); cmd.off('error', writeFunction);
@ -184,16 +184,14 @@ export default class Util {
} }
public async createHash(password: string): Promise<string> { public async createHash(password: string): Promise<string> {
const hashed = await this.exec(`mkpasswd -m sha-512 "${password}"`); return this.exec(`mkpasswd -m sha-512 "${password}"`);
return hashed;
} }
public isValidEmail(email: string): boolean { public isValidEmail(email: string): boolean {
const checkAt = email.indexOf('@'); const checkAt = email.indexOf('@');
if (checkAt < 1) return false; if (checkAt < 1) return false;
const checkDomain = email.indexOf('.', checkAt + 2); const checkDomain = email.indexOf('.', checkAt + 2);
if (checkDomain < checkAt) return false; return checkDomain >= checkAt;
return true;
} }
public randomPassword(): string { public randomPassword(): string {