qol changes for Util.ts

master
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

@ -5,14 +5,14 @@ import axios from 'axios';
import {randomBytes} from 'crypto';
import childProcess from 'child_process';
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 moment from 'moment';
import fs from 'fs';
import hastebin from 'hastebin-gen';
import {getUserByUid} from '../functions';
import {AccountUtil, Client, Command, PaginationEmbed} from '.';
import { ModerationInterface, AccountInterface } from '../models';
import {AccountInterface, ModerationInterface} from '../models';
import {Certificate} from '../../types/x509';
export default class Util {
@ -46,7 +46,7 @@ export default class Util {
cmd.stdout.on('data', writeFunction);
cmd.stderr.on('data', writeFunction);
cmd.on('error', writeFunction);
cmd.once('close', (code, signal) => {
cmd.once('close', (code) => {
cmd.stdout.off('data', writeFunction);
cmd.stderr.off('data', writeFunction);
cmd.off('error', writeFunction);
@ -184,16 +184,14 @@ export default class Util {
}
public async createHash(password: string): Promise<string> {
const hashed = await this.exec(`mkpasswd -m sha-512 "${password}"`);
return hashed;
return this.exec(`mkpasswd -m sha-512 "${password}"`);
}
public isValidEmail(email: string): boolean {
const checkAt = email.indexOf('@');
if (checkAt < 1) return false;
const checkDomain = email.indexOf('.', checkAt + 2);
if (checkDomain < checkAt) return false;
return true;
return checkDomain >= checkAt;
}
public randomPassword(): string {