1
0
Fork 0

Compare commits

..

No commits in common. "17b567b00fed2802cb6cfba183d2de234091ad87" and "1e73890594714c8ef38edeffe49d38951a291fbc" have entirely different histories.

9 changed files with 106 additions and 117 deletions

View File

@ -41,13 +41,13 @@ export default class AccountUtil {
subject: 'Approval for CS Account', subject: 'Approval for CS Account',
html: ` html: `
<body> <body>
<style>* {font-family: 'Calibri',sans-serif;}</style> <style>* {font-family: 'Calibri';}</style>
<h1>Library of Code | Cloud Services</h1> <h1>Library of Code | Cloud Services</h1>
<h2>Congratulations, your CS Account application has been approved. Welcome! Please see below for some details regarding your account and our services</h2> <h2>Congratulations, your CS Account application has been approved. Welcome! Please see below for some details regarding your account and our services</h2>
<p><b>Username:</b> ${data.username}</p> <p><b>Username:</b> ${data.username}</p>
<p><b>Support Key:</b> ${code} || <i>You may be asked for this support key when contacting Library of Code, please keep the code in a safe area.</i></p> <p><b>Support Key:</b> ${code} || <i>You may be asked for this support key when contacting Library of Code, please keep the code in a safe area.</i></p>
<p><b>SSH Login:</b> <pre><code style="font-family: Courier,sans-serif;">ssh ${data.username}@cloud.libraryofcode.org</code></pre> <p><b>SSH Login:</b> <pre><code style="font-family: Courier;">ssh ${data.username}@cloud.libraryofcode.org</code></pre>
<p><b>Underwritten by:</b> ${moderatorMember.user.username}${find.isManager ? ' [k]' : ' '}</p> <p><b>Underwritten by:</b> ${moderatorMember.user.username}, ${find.pn.join(', ')}
<h2>Useful information</h2> <h2>Useful information</h2>
<h3>How to log in:</h3> <h3>How to log in:</h3>
<ol> <ol>
@ -76,20 +76,16 @@ export default class AccountUtil {
const member = guild.members.cache.get(data.userID); const member = guild.members.cache.get(data.userID);
await member.roles.add('546457886440685578'); await member.roles.add('546457886440685578');
const user = this.client.users.cache.get(data.userID); const user = this.client.users.cache.get(data.userID);
try { user.send('<:loc:607695848612167700> **Thank you for creating an account with us!** <:loc:607695848612167700>\n'
await user.send('<:loc:607695848612167700> **Thank you for creating an account with us!** <:loc:607695848612167700>\n' + `Please log into your account by running \`ssh ${data.username}@cloud.libraryofcode.org\` in your terminal, then use the password \`${tempPass}\` to log in.\n`
+ `Please log into your account by running \`ssh ${data.username}@cloud.libraryofcode.org\` in your terminal, then use the password \`${tempPass}\` to log in.\n` + `You will be asked to change your password, \`(current) UNIX password\` is \`${tempPass}\`, then create a password that is at least 12 characters long, with at least one number, special character, and an uppercase letter\n`
+ `You will be asked to change your password, \`(current) UNIX password\` is \`${tempPass}\`, then create a password that is at least 12 characters long, with at least one number, special character, and an uppercase letter\n` + 'Bear in mind that when you enter your password, it will be blank, so be careful not to type in your password incorrectly.\n\n'
+ 'Bear in mind that when you enter your password, it will be blank, so be careful not to type in your password incorrectly.\n\n' + 'An email containing some useful information has also been sent.\n'
+ 'An email containing some useful information has also been sent.\n' + `Your support key is \`${code}\`. Pin this message, you may need this key to contact Library of Code in the future.`).catch();
+ `Your support key is \`${code}\`. Pin this message, you may need this key to contact Library of Code in the future.`);
} catch (error) {
this.client.util.handleError(error);
}
return { account: accountInterface, tempPass }; return { account: accountInterface, tempPass };
} }
public async lock(username: string, moderatorID: string, data?: { reason?: string, time?: number }) { public async lock(username: string, moderatorID: string, data?: { reason?: string, time?: number}) {
const account = await this.client.db.Account.findOne({ username }); const account = await this.client.db.Account.findOne({ username });
if (!account) throw new Error('Account does not exist.'); if (!account) throw new Error('Account does not exist.');
if (account.locked) throw new Error('Account is already locked.'); if (account.locked) throw new Error('Account is already locked.');

View File

@ -5,22 +5,16 @@ 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 { ColorResolvable, DMChannel, Message, MessageEmbed, TextChannel, User } from 'discord.js'; import { Message, DMChannel, User, MessageEmbed, ColorResolvable, TextChannel } 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 { AccountInterface, ModerationInterface } from '../models'; import { ModerationInterface, AccountInterface } from '../models';
import { Certificate } from '../../types/x509'; import { Certificate } from '../../types/x509';
enum TechnicianNameFormatOpt {
Full = 0,
Partial,
Basic
}
export default class Util { export default class Util {
public client: Client; public client: Client;
@ -52,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) => { cmd.once('close', (code, signal) => {
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);
@ -190,14 +184,16 @@ export default class Util {
} }
public async createHash(password: string): Promise<string> { public async createHash(password: string): Promise<string> {
return this.exec(`mkpasswd -m sha-512 "${password}"`); const hashed = await 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);
return checkDomain >= checkAt; if (checkDomain < checkAt) return false;
return true;
} }
public randomPassword(): string { public randomPassword(): string {
@ -280,7 +276,7 @@ export default class Util {
} else date = null; } else date = null;
} }
const expiration: { date: Date; processed: boolean } = { date, processed }; const expiration = { date, processed };
logInput.expiration = expiration; logInput.expiration = expiration;
const log = new this.client.db.Moderation(logInput); const log = new this.client.db.Moderation(logInput);
@ -294,8 +290,8 @@ export default class Util {
case 0: archType = 'Technician'; embedTitle = 'Cloud Account | Create'; color = '#00ff00'; break; case 0: archType = 'Technician'; embedTitle = 'Cloud Account | Create'; color = '#00ff00'; break;
case 1: archType = 'Technician'; embedTitle = 'Account Warning | Warn'; color = '#ffff00'; break; case 1: archType = 'Technician'; embedTitle = 'Account Warning | Warn'; color = '#ffff00'; break;
case 2: archType = 'Technician'; embedTitle = 'Account Infraction | Lock'; color = '#ff6600'; break; case 2: archType = 'Technician'; embedTitle = 'Account Infraction | Lock'; color = '#ff6600'; break;
case 3: archType = 'Technician'; embedTitle = 'Account Infraction | Unlock'; color = '#0099ff'; break; case 3: archType = 'Technician'; embedTitle = 'Account Reclaim | Unlock'; color = '#0099ff'; break;
case 4: archType = 'Manager'; embedTitle = 'Cloud Account | Delete'; color = '#ff0000'; break; case 4: archType = 'Director'; embedTitle = 'Cloud Account | Delete'; color = '#ff0000'; break;
} }
const req = await axios.get('https://loc.sh/int/directory'); const req = await axios.get('https://loc.sh/int/directory');
const find = req.data.find((mem) => mem.userID === moderator.id); const find = req.data.find((mem) => mem.userID === moderator.id);
@ -303,7 +299,7 @@ export default class Util {
.setTitle(embedTitle) .setTitle(embedTitle)
.setColor(color) .setColor(color)
.addField('User', `${username} | <@${userID}>`, true) .addField('User', `${username} | <@${userID}>`, true)
.addField(archType, moderatorID === this.client.user.id ? 'SYSTEM' : `${moderator.username}${find.isManager ? ' [k] ' : ' '}(<@${moderatorID}>)`, true) .addField(archType, moderatorID === this.client.user.id ? 'SYSTEM' : `${moderator.username}, ${find.pn.join(', ')} (<@${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');
@ -315,19 +311,13 @@ export default class Util {
return Promise.resolve(log); return Promise.resolve(log);
} }
public async getTechnicianName(tech: User, format: TechnicianNameFormatOpt = TechnicianNameFormatOpt.Full) { public async getTechnicianFullName(tech: User) {
if (!tech) return 'SYSTEM (UT)'; if (!tech) throw new Error('\'tech\' is undefined.');
if (tech.id === this.client.user.id) return 'SYSTEM (SELF)'; if (tech.id === this.client.user.id) return 'SYSTEM';
const req = await axios.get('https://loc.sh/int/directory'); const req = await axios.get('https://loc.sh/int/directory');
const find = req.data.find((mem) => mem.userID === tech.id); const find = req.data.find((mem) => mem.userID === tech.id);
if (!find) return 'SYSTEM (UF)'; return `${tech.username}${find.isManager ? '[k]' : ''}${find.title ? ` (${find.title} / ${find.dept})` : ` (${find.dept})`} <<@${tech.id}>>`;
if (format === TechnicianNameFormatOpt.Full) {
return `${tech.username}${find.isManager ? ' [k]' : ''}${find.title ? ` (${find.title} / ${find.dept})` : ` (${find.dept})`} <<@${tech.id}>>`;
} else if (format === TechnicianNameFormatOpt.Partial) {
return `${tech.username}${find.isManager ? ' [k]' : ''}${find.title ? ` (${find.title})` : ` (${find.dept})`} <<@${tech.id}>>`;
}
return `${tech.username}${find.isManager ? ' [k]' : ''} <<@${tech.id}>>`;
} }
public parseCertificate(pem: string) { public parseCertificate(pem: string) {

View File

@ -84,7 +84,7 @@ export default class CWG_Create extends Command {
.setTitle('Domain Creation') .setTitle('Domain Creation')
.setColor(3066993) .setColor(3066993)
.addField('Account Username', `${account.username} | <@${account.userID}>`, true) .addField('Account Username', `${account.username} | <@${account.userID}>`, true)
.addField('Technician', await this.client.util.getTechnicianName(message.author), true) .addField('Technician', await this.client.util.getTechnicianFullName(message.author), true)
.addField('Domain', domain.domain, true) .addField('Domain', domain.domain, true)
.addField('Port', String(domain.port), true); .addField('Port', String(domain.port), true);

View File

@ -1,61 +1,61 @@
import fs from 'fs-extra'; import fs from 'fs-extra';
import axios from 'axios'; import axios from 'axios';
import { Message, MessageEmbed, TextChannel } from 'discord.js'; import { Message, MessageEmbed, TextChannel } from 'discord.js';
import { Client, Command } from '../class'; import { Client, Command } from '../class';
export default class CWG_Delete extends Command { export default class CWG_Delete extends Command {
constructor(client: Client) { constructor(client: Client) {
super(client); super(client);
this.name = 'delete'; this.name = 'delete';
this.description = 'Unbind a domain from the CWG'; this.description = 'Unbind a domain from the CWG';
this.usage = `${this.client.config.prefix}cwg delete [Domain | Port]`; this.usage = `${this.client.config.prefix}cwg delete [Domain | Port]`;
this.permissions = { roles: ['662163685439045632', '701454780828221450'] }; this.permissions = { roles: ['662163685439045632', '701454780828221450'] };
this.aliases = ['unbind']; this.aliases = ['unbind'];
this.enabled = true; this.enabled = true;
} }
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
if (!args[0]) return this.client.commands.get('help').run(message, ['cwg', this.name]); if (!args[0]) return this.client.commands.get('help').run(message, ['cwg', this.name]);
const domain = await this.client.db.Domain.findOne({ $or: [{ domain: args[0] }, { port: Number(args[0]) || 0 }] }); const domain = await this.client.db.Domain.findOne({ $or: [{ domain: args[0] }, { port: Number(args[0]) || 0 }] });
if (!domain) return this.error(message.channel, 'The domain or port you provided could not be found.'); if (!domain) return this.error(message.channel, 'The domain or port you provided could not be found.');
const edit = await this.loading(message.channel, 'Deleting domain...'); const edit = await this.loading(message.channel, 'Deleting domain...');
const embed = new MessageEmbed(); const embed = new MessageEmbed();
embed.setTitle('Domain Deletion'); embed.setTitle('Domain Deletion');
embed.addField('Account Username', `${domain.account.username} | <@${domain.account.userID}>`, true); embed.addField('Account Username', `${domain.account.username} | <@${domain.account.userID}>`, true);
embed.addField('Technician', await this.client.util.getTechnicianName(message.author), true); embed.addField('Technician', await this.client.util.getTechnicianFullName(message.author), true);
embed.addField('Domain', domain.domain, true); embed.addField('Domain', domain.domain, true);
embed.addField('Port', String(domain.port), true); embed.addField('Port', String(domain.port), true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL()); embed.setFooter(this.client.user.username, this.client.user.avatarURL());
embed.setTimestamp(); embed.setTimestamp();
if (domain.domain.includes('cloud.libraryofcode.org')) { if (domain.domain.includes('cloud.libraryofcode.org')) {
const resultID = await axios({ const resultID = await axios({
method: 'get', method: 'get',
url: `https://api.cloudflare.com/client/v4/zones/5e82fc3111ed4fbf9f58caa34f7553a7/dns_records?name=${domain.domain}`, url: `https://api.cloudflare.com/client/v4/zones/5e82fc3111ed4fbf9f58caa34f7553a7/dns_records?name=${domain.domain}`,
headers: { Authorization: `Bearer ${this.client.config.cloudflare}` }, headers: { Authorization: `Bearer ${this.client.config.cloudflare}` },
}); });
this.client.signale.debug(resultID.data); this.client.signale.debug(resultID.data);
if (resultID.data.result[0]) { if (resultID.data.result[0]) {
const recordID = resultID.data.result[0].id; const recordID = resultID.data.result[0].id;
await axios({ await axios({
method: 'delete', method: 'delete',
url: `https://api.cloudflare.com/client/v4/zones/5e82fc3111ed4fbf9f58caa34f7553a7/dns_records/${recordID}`, url: `https://api.cloudflare.com/client/v4/zones/5e82fc3111ed4fbf9f58caa34f7553a7/dns_records/${recordID}`,
headers: { Authorization: `Bearer ${this.client.config.cloudflare}` }, headers: { Authorization: `Bearer ${this.client.config.cloudflare}` },
}); });
} }
} }
try { try {
await fs.unlink(`/etc/nginx/sites-enabled/${domain.domain}`); await fs.unlink(`/etc/nginx/sites-enabled/${domain.domain}`);
await fs.unlink(`/etc/nginx/sites-available/${domain.domain}`); await fs.unlink(`/etc/nginx/sites-available/${domain.domain}`);
} catch (e) { this.client.signale.error(e); } } catch (e) { this.client.signale.error(e); }
await this.client.db.Domain.deleteOne({ domain: domain.domain }); await this.client.db.Domain.deleteOne({ domain: domain.domain });
await this.client.util.exec('systemctl reload nginx'); await this.client.util.exec('systemctl reload nginx');
edit.edit(`***${this.client.stores.emojis.success} Domain ${domain.domain} with port ${domain.port} has been successfully deleted.***`); edit.edit(`***${this.client.stores.emojis.success} Domain ${domain.domain} with port ${domain.port} has been successfully deleted.***`);
const ch = this.client.channels.cache.get('580950455581147146') as TextChannel; const ch = this.client.channels.cache.get('580950455581147146') as TextChannel;
ch.send({ embeds: [embed] }); ch.send({ embeds: [embed] });
return this.client.users.fetch(domain.account.userID).then((u) => u.send({ embeds: [embed] })).catch(() => {}); return this.client.users.fetch(domain.account.userID).then((u) => u.send({ embeds: [embed] })).catch(() => {});
} catch (error) { } catch (error) {
return this.client.util.handleError(error, message, this); return this.client.util.handleError(error, message, this);
} }
} }
} }

View File

@ -30,7 +30,7 @@ export default class Notify extends Command {
embed.addField('User', `${account.username} | <@${account.userID}>`, true); embed.addField('User', `${account.username} | <@${account.userID}>`, true);
const req = await axios.get('https://loc.sh/int/directory'); const req = await axios.get('https://loc.sh/int/directory');
const technician = req.data.find((mem) => mem.userID === message.author.id); const technician = req.data.find((mem) => mem.userID === message.author.id);
embed.addField('Technician', message.author.id === this.client.user.id ? 'SYSTEM' : `${message.author.username}${technician.isManager ? ' [k] ' : ' '}(<@${message.author.id}>)`, true); embed.addField('Technician', message.author.id === this.client.user.id ? 'SYSTEM' : `${message.author.username}, ${technician.pn.join(', ')} (<@${message.author.id}>)`, true);
const ch = this.client.channels.cache.get('580950455581147146') as TextChannel; const ch = this.client.channels.cache.get('580950455581147146') as TextChannel;
ch.send({ embeds: [embed] }); ch.send({ embeds: [embed] });
this.client.util.transport.sendMail({ this.client.util.transport.sendMail({

View File

@ -31,7 +31,8 @@ export default class ResetPassword extends Command {
+ `You will be asked to change your password when you log back in, \`(current) UNIX password\` is \`${tempPass}@\`, then create a password that is at least 12 characters long, with at least one number, special character, and an uppercase letter.\n` + `You will be asked to change your password when you log back in, \`(current) UNIX password\` is \`${tempPass}@\`, then create a password that is at least 12 characters long, with at least one number, special character, and an uppercase letter.\n`
+ 'Bear in mind that when you enter your password, it will be blank, so be careful not to type in your password incorrectly.'); + 'Bear in mind that when you enter your password, it will be blank, so be careful not to type in your password incorrectly.');
} catch (error) { } catch (error) {
completeMessage += '\n*Unable to DM user*'; if (error.code === 50007) completeMessage += '\n*Unable to DM user*';
throw error;
} }
return msg.edit(completeMessage); return msg.edit(completeMessage);
} catch (error) { } catch (error) {

View File

@ -18,8 +18,8 @@ export default class Tier extends Command {
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] }); const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] });
if (!account) return edit.edit(`***${this.client.stores.emojis.error} Cannot find user.***`); if (!account) return edit.edit(`***${this.client.stores.emojis.error} Cannot find user.***`);
if (account.root) return edit.edit(`***${this.client.stores.emojis.error} Permission denied.***`); if (account.root) return edit.edit(`***${this.client.stores.emojis.error} Permission denied.***`);
if (Number.isNaN(Number(args[1]))) return edit.edit(`***${this.client.stores.emojis.error} The tier you provided is not a valid number. It should be between 0 and 3.***`); if (Number.isNaN(Number(args[1]))) return edit.edit(`***${this.client.stores.emojis.error} The tier you provided is not a valid number. It should be between 1 and 3.***`);
if (Number(args[1]) > 3 || Number(args[1]) < 0) return edit.edit(`***${this.client.stores.emojis.error} You can only choose a Tier between 0 and 3.***`); if (Number(args[1]) > 3 || Number(args[1]) < 1) return edit.edit(`***${this.client.stores.emojis.error} You can only choose a Tier between 1 and 3.***`);
message.delete(); message.delete();
const tier = await this.client.db.Tier.findOne({ id: Number(args[1]) }); const tier = await this.client.db.Tier.findOne({ id: Number(args[1]) });
if (account.ramLimitNotification !== -1) { if (account.ramLimitNotification !== -1) {
@ -32,7 +32,7 @@ export default class Tier extends Command {
embed.setTitle('Cloud Account | Tier Change'); embed.setTitle('Cloud Account | Tier Change');
embed.setColor('#0099ff'); embed.setColor('#0099ff');
embed.addField('User', `${account.username} | <@${account.userID}>`, true); embed.addField('User', `${account.username} | <@${account.userID}>`, true);
embed.addField('Technician', await this.client.util.getTechnicianName(message.author), true); embed.addField('Technician', await this.client.util.getTechnicianFullName(message.author), true);
embed.addField('Old Tier -> New Tier', `${account.tier} -> ${args[1]}`, true); embed.addField('Old Tier -> New Tier', `${account.tier} -> ${args[1]}`, true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL()); embed.setFooter(this.client.user.username, this.client.user.avatarURL());
embed.setTimestamp(); embed.setTimestamp();

View File

@ -46,7 +46,7 @@ export default class Whois extends Command {
if (account.locked) details += '__This account is currently locked.__\n'; if (account.locked) details += '__This account is currently locked.__\n';
switch (true) { switch (true) {
case account.permissions.director: case account.permissions.director:
details += 'This account belongs to a Manager.\n'; details += 'This account belongs to a Director.\n';
role = await message.member.guild.roles.fetch('662163685439045632'); role = await message.member.guild.roles.fetch('662163685439045632');
break; break;
case account.permissions.technician: case account.permissions.technician:
@ -61,12 +61,11 @@ export default class Whois extends Command {
role = await message.member.guild.roles.fetch(message.member.guild.id); role = await message.member.guild.roles.fetch(message.member.guild.id);
break; break;
} }
if (account.root) details += '**This account has administrative privileges.**\n'; if (account.root) details += '**This account has root/administrative privileges.**\n';
embed.setColor(role.color || 0x36393f); embed.setColor(role.color || 0x36393f);
if (details) embed.addField('Additional Details', details, true); if (details) embed.addField('Additional Details', details, true);
embed.setTimestamp(); embed.setTimestamp();
embed.setFooter('Library of Code | Cloud Services', message.guild.iconURL());
return message.channel.send({ embeds: [embed] }); return message.channel.send({ embeds: [embed] });
} catch (error) { } catch (error) {
return this.client.util.handleError(error, message, this); return this.client.util.handleError(error, message, this);
@ -84,13 +83,15 @@ export default class Whois extends Command {
const finger = !member.roles.cache.has('662163685439045632') ? fingerInformation.replace(this.IP_REGEX, '[MASKED IP ADDRESS]') : fingerInformation; const finger = !member.roles.cache.has('662163685439045632') ? fingerInformation.replace(this.IP_REGEX, '[MASKED IP ADDRESS]') : fingerInformation;
embed.setDescription(`${finger}\n${chage}`); embed.setDescription(`${finger}\n${chage}`);
embed.addField('Username', `${account.username} <<@${account.userID}>>`, true); embed.addField('Username', `${account.username} | <@${account.userID}>`, true);
embed.addField('Discord ID', account.userID, true); embed.addField('ID', account.userID, true);
embed.addField('Email Address', account.emailAddress, true); embed.addField('Email Address', account.emailAddress, true);
embed.addField('Tier', String(account.tier), true); embed.addField('Tier', String(account.tier), true);
embed.addField('Support Key', account.supportKey, true); embed.addField('Support Key', account.supportKey, true);
embed.addField('Referral Code & Total', `${account.referralCode} | ${account.totalReferrals}`, true); embed.addField('Referral Code & Total', `${account.referralCode} | ${account.totalReferrals}`, true);
embed.addField('Created By', (await this.client.util.getTechnicianName(await this.client.users.fetch(account.createdBy))), true); embed.addField('Created By', await this.client.users.fetch(account.createdBy)
? (await this.client.users.fetch(account.createdBy)).toString()
: 'SYSTEM', true);
embed.addField('Created At', moment(account.createdAt).format('dddd, MMMM Do YYYY, h:mm:ss A'), true); embed.addField('Created At', moment(account.createdAt).format('dddd, MMMM Do YYYY, h:mm:ss A'), true);
embed.addField('CPU Usage', `${cpuUsage.split('\n')[0] || '0'}%`, true); embed.addField('CPU Usage', `${cpuUsage.split('\n')[0] || '0'}%`, true);
embed.addField('Memory', dataConversion(Number(memory) * 1000), true); embed.addField('Memory', dataConversion(Number(memory) * 1000), true);
@ -104,11 +105,12 @@ export default class Whois extends Command {
this.client.util.exec(`memory ${account.username}`), this.client.util.exec(`memory ${account.username}`),
]); ]);
embed.setDescription('*CPU Usage and Memory are fetched in real-time, storage information is cached.*'); embed.addField('Username', `${account.username} | <@${account.userID}>`, true);
embed.addField('Username', `${account.username} <<@${account.userID}>>`, true); embed.addField('ID', account.userID, true);
embed.addField('Discord ID', account.userID, true);
embed.addField('Tier', String(account.tier), true); embed.addField('Tier', String(account.tier), true);
embed.addField('Created By', (await this.client.util.getTechnicianName(await this.client.users.fetch(account.createdBy), 2)), true); embed.addField('Created By', await this.client.users.fetch(account.createdBy)
? (await this.client.users.fetch(account.createdBy)).toString()
: 'SYSTEM', true);
embed.addField('Created At', moment(account.createdAt).format('dddd, MMMM Do YYYY, h:mm:ss A'), true); embed.addField('Created At', moment(account.createdAt).format('dddd, MMMM Do YYYY, h:mm:ss A'), true);
embed.addField('CPU Usage', `${cpuUsage.split('\n')[0] || '0'}%`, true); embed.addField('CPU Usage', `${cpuUsage.split('\n')[0] || '0'}%`, true);
embed.addField('Memory', dataConversion(Number(memory) * 1000), true); embed.addField('Memory', dataConversion(Number(memory) * 1000), true);

View File

@ -52,7 +52,7 @@ export default function checkStaffStatus(client: Client) {
await client.db.Account.updateOne({ username: acc.username }, { $set: { 'permissions.intern': false } }); await client.db.Account.updateOne({ username: acc.username }, { $set: { 'permissions.intern': false } });
} }
if ((acc.permissions.staff || acc.permissions.intern || acc.permissions.technician || acc.permissions.director || user.roles.cache.has('858049948401401866')) && (acc.tier < 3 && acc.tier > 0)) { if ((acc.permissions.staff || acc.permissions.intern || acc.permissions.technician || acc.permissions.director || user.roles.cache.has('858049948401401866')) && acc.tier < 3) {
await client.db.Account.updateOne({ username: acc.username }, { $set: { tier: 3 } }); await client.db.Account.updateOne({ username: acc.username }, { $set: { tier: 3 } });
const embed = new MessageEmbed(); const embed = new MessageEmbed();
embed.setTitle('Cloud Account | Tier Change'); embed.setTitle('Cloud Account | Tier Change');