1
0
Fork 0

QOL improvements

refactor/models
Matthew 2021-04-18 19:35:29 -04:00
parent a28fbc5f34
commit 679f76e251
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
3 changed files with 16 additions and 8 deletions

View File

@ -1,3 +1,4 @@
import axios from 'axios';
import moment from 'moment'; import moment from 'moment';
import { randomBytes } from 'crypto'; import { randomBytes } from 'crypto';
import { AccountInterface } from '../models'; import { AccountInterface } from '../models';
@ -28,20 +29,23 @@ export default class AccountUtil {
const accountInterface = await this.client.util.createAccount(passHash, etcPasswd, data.username, data.userID, data.emailAddress, moderator, code); const accountInterface = await this.client.util.createAccount(passHash, etcPasswd, data.username, data.userID, data.emailAddress, moderator, code);
await this.client.util.createModerationLog(data.userID, moderatorMember, 0); await this.client.util.createModerationLog(data.userID, moderatorMember, 0);
const req = await axios.get('https://loc.sh/int/directory');
const find = req.data.find((mem) => mem.userID === moderator);
this.client.util.transport.sendMail({ this.client.util.transport.sendMail({
to: data.emailAddress, to: data.emailAddress,
from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>', from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>',
replyTo: 'cloud-help@libraryofcode.org', replyTo: 'cloud-help@libraryofcode.org',
subject: 'Your account has been created!', subject: 'Approval for CS Account',
html: ` html: `
<body> <body>
<style>* {font-family: 'Calibri';}</style> <style>* {font-family: 'Calibri';}</style>
<h1>Library of Code | Cloud Services</h1> <h1>Library of Code | Cloud Services</h1>
<h2>Your Cloud Account has been created, 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;">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.pn.join(', ')}
<h2>Useful information</h2> <h2>Useful information</h2>
<h3>How to log in:</h3> <h3>How to log in:</h3>
<ol> <ol>
@ -53,14 +57,15 @@ export default class AccountUtil {
<h3>Channels and Links</h3> <h3>Channels and Links</h3>
<ul> <ul>
<li><a target="_blank" href="https://discordapp.com/channels/446067825673633794/622856541325885453">#status</a> - You can find the status of all our services, including the cloud machine, here</li> <li><a target="_blank" href="https://status.libraryofcode.org/">Status Page</a> - You can find the status of all our services, including the cloud machine, here.</li>
<li><a target="_blank" href="https://status.libraryofcode.org/">Wiki</a> - Wiki site, includes information about the Cloud Server.</li>
<li><a target="_blank" href="https://discordapp.com/channels/446067825673633794/620355063088414769">#cloud-announcements</a> - Announcements regarding the cloud machine will be here. These include planned maintenance, updates to preinstalled services etc.</li> <li><a target="_blank" href="https://discordapp.com/channels/446067825673633794/620355063088414769">#cloud-announcements</a> - Announcements regarding the cloud machine will be here. These include planned maintenance, updates to preinstalled services etc.</li>
<li><a target="_blank" href="https://discordapp.com/channels/446067825673633794/620349128295186472">#cloud-info</a> - Important information you will need to, or should, know to a certain extent. These include our infractions system and Tier limits</li> <li><a target="_blank" href="https://discordapp.com/channels/446067825673633794/620349128295186472">#cloud-info</a> - Important information you will need to, or should, know to a certain extent.</li>
<li><a target="_blank" href="https://discordapp.com/channels/446067825673633794/546457788184789013">#cloud-support</a> - A support channel specifically for the cloud machine, you can use this to ask how to renew your certificates, for example</li> <li><a target="_blank" href="https://discordapp.com/channels/446067825673633794/546457788184789013">#cloud-support</a> - A support channel specifically for the cloud machine.</li>
<li><a target="_blank" href="https://loc.sh/cs-help">Library of Code Support Desk</a> - Our Support desk, you can contact Staff here.</li> <li><a target="_blank" href="https://loc.sh/cs-help">Library of Code Support Desk</a> - Our Support desk, you can contact Staff here.</li>
</ul> </ul>
<h3>Want to support us?</h3> <h3>Want to support us?</h3>
<p>You can support us on Patreon! Head to <a target="_blank" href="https://loc.sh/donate">our Patreon page</a> and feel free to donate as much or as little as you want!<br>Donating $5 or more will grant you Tier 3, which means we will manage your account at your request, longer certificates, increased Tier limits as well as some roles in the server!</p> <p>You can support us by purchasing a Tier 3 subscription! <a target="_blank" href="https://canary.discord.com/channels/446067825673633794/620355063088414769/774938174001774592">this site</a> for more information.</p>
<b><i>Library of Code sp-us | Support Team</i></b> <b><i>Library of Code sp-us | Support Team</i></b>
</body> </body>
`, `,

View File

@ -1,5 +1,6 @@
/* 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 { 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';
@ -286,11 +287,13 @@ export default class Util {
case 3: archType = 'Technician'; embedTitle = 'Account Reclaim | Unlock'; color = '0099ff'; break; case 3: archType = 'Technician'; embedTitle = 'Account Reclaim | Unlock'; color = '0099ff'; break;
case 4: archType = 'Director'; 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 find = req.data.find((mem) => mem.userID === moderator.id);
const embed = new RichEmbed() const embed = new RichEmbed()
.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' : `<@${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');

View File

@ -40,7 +40,7 @@ export default class DeleteAccount extends Command {
if (reason) logInput.reason = reason; if (reason) logInput.reason = reason;
await this.client.util.createModerationLog(args[0], message.member, 4, reason); await this.client.util.createModerationLog(args[0], message.member, 4, reason);
await this.client.util.deleteAccount(username); await this.client.util.deleteAccount(username);
await message.delete().catch(() => {}); message.delete().catch(() => {});
this.client.util.transport.sendMail({ this.client.util.transport.sendMail({
to: account.emailAddress, to: account.emailAddress,