forked from engineering/cloudservices
add referral codes
parent
85f1da2f95
commit
079887ac8a
|
@ -32,6 +32,7 @@ export default class AccountUtil {
|
|||
this.client.util.transport.sendMail({
|
||||
to: data.emailAddress,
|
||||
from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>',
|
||||
replyTo: 'cloud-help@libraryofcode.org',
|
||||
subject: 'Your account has been created!',
|
||||
html: `
|
||||
<body>
|
||||
|
@ -89,6 +90,7 @@ export default class AccountUtil {
|
|||
this.client.util.transport.sendMail({
|
||||
to: account.emailAddress,
|
||||
from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>',
|
||||
replyTo: 'cloud-help@libraryofcode.org',
|
||||
subject: 'Your account has been locked',
|
||||
html: `
|
||||
<h1>Library of Code | Cloud Services</h1>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable no-await-in-loop */
|
||||
/* eslint-disable no-param-reassign */
|
||||
import { promisify, inspect } from 'util';
|
||||
import { randomBytes } from 'crypto';
|
||||
import childProcess from 'child_process';
|
||||
import nodemailer from 'nodemailer';
|
||||
import { Message, PrivateChannel, GroupChannel, Member, User } from 'eris';
|
||||
|
@ -203,7 +203,7 @@ export default class Util {
|
|||
const tier = await this.client.db.Tier.findOne({ id: 1 });
|
||||
|
||||
const account = new this.client.db.Account({
|
||||
username, userID, emailAddress, createdBy: moderatorID, createdAt: new Date(), locked: false, tier: 1, supportKey: code, ssInit: false, ramLimitNotification: tier.resourceLimits.ram - 50, homepath: `/home/${username}`,
|
||||
username, userID, emailAddress, createdBy: moderatorID, createdAt: new Date(), locked: false, tier: 1, supportKey: code, totalReferrals: 0, referralCode: randomBytes(9).toString('base64').toUpperCase(), ssInit: false, ramLimitNotification: tier.resourceLimits.ram - 50, homepath: `/home/${username}`,
|
||||
});
|
||||
return account.save();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
import { Message } from 'eris';
|
||||
import { Client, Command } from '../class';
|
||||
|
||||
export default class AddReferral extends Command {
|
||||
constructor(client: Client) {
|
||||
super(client);
|
||||
this.name = 'addreferral';
|
||||
this.description = 'Adds a referral value to an account.';
|
||||
this.permissions = { roles: ['662163685439045632', '701454780828221450'] };
|
||||
this.enabled = true;
|
||||
this.aliases = ['af', 'refer'];
|
||||
this.usage = `${this.client.config.prefix}addreferral <user>`;
|
||||
}
|
||||
|
||||
public async run(message: Message, args: string[]) { // eslint-disable-line
|
||||
try {
|
||||
if (!args.length) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
if (!account) return this.error(message.channel, 'Cannot find user.');
|
||||
|
||||
await account.updateOne({ $inc: { totalReferrals: 1 } });
|
||||
return this.success(message.channel, 'Added referral value to account.');
|
||||
} catch (error) {
|
||||
return this.client.util.handleError(error, message, this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -83,9 +83,9 @@ export default class CWG_Create extends Command {
|
|||
const embed = new RichEmbed()
|
||||
.setTitle('Domain Creation')
|
||||
.setColor(3066993)
|
||||
.addField('Account Username', account.username, true)
|
||||
.addField('Account Username', `${account.username} | <@${account.userID}>`, true)
|
||||
.addField('Account ID', account.id, true)
|
||||
.addField('Engineer', `<@${message.author.id}>`, true)
|
||||
.addField('Technician', `<@${message.author.id}>`, true)
|
||||
.addField('Domain', domain.domain, true)
|
||||
.addField('Port', String(domain.port), true);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ export default class CWG_Delete extends Command {
|
|||
const edit = await this.loading(message.channel, 'Deleting domain...');
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle('Domain Deletion');
|
||||
embed.addField('Account Username', domain.account.username, true);
|
||||
embed.addField('Account Username', `${domain.account.username} | <@${domain.account.userID}>`, true);
|
||||
embed.addField('Account ID', domain.account.userID, true);
|
||||
embed.addField('Domain', domain.domain, true);
|
||||
embed.addField('Port', String(domain.port), true);
|
||||
|
|
|
@ -45,6 +45,7 @@ export default class DeleteAccount extends Command {
|
|||
this.client.util.transport.sendMail({
|
||||
to: account.emailAddress,
|
||||
from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>',
|
||||
replyTo: 'cloud-help@libraryofcode.org',
|
||||
subject: 'Your account has been deleted',
|
||||
html: `
|
||||
<h1>Library of Code | Cloud Services</h1>
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
import { Message } from 'eris';
|
||||
import { Client, Command } from '../class';
|
||||
|
||||
export default class GetReferral extends Command {
|
||||
constructor(client: Client) {
|
||||
super(client);
|
||||
this.name = 'getreferral';
|
||||
this.description = 'Fetches your referral code.';
|
||||
this.usage = `${this.client.config.prefix}getreferral`;
|
||||
this.aliases = ['gf'];
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, ['getreferral', this.name]);
|
||||
const account = await this.client.db.Account.findOne({ userID: message.author.id });
|
||||
if (!account) return this.error(message.channel, 'You do not have a Cloud Services account.');
|
||||
|
||||
return this.client.getDMChannel(message.author.id).then((chan) => {
|
||||
chan.createMessage(`__**CS Account Referral Code**__\n*Referral codes are considered to be somewhat private information. Applicants with referral codes have a greater chance of approval, don't refer someone you don't trust :).*\nYour referral code: \`${account.referralCode}\`\nReferrals Granted: \`${account.totalReferrals ? account.totalReferrals : '0'}`);
|
||||
}).catch(() => this.error(message.channel, 'Could not send you a DM.'));
|
||||
} catch (err) {
|
||||
return this.client.util.handleError(err, message, this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
export { default as addreferral } from './addreferral';
|
||||
export { default as announce } from './announce';
|
||||
export { default as bearer } from './bearer';
|
||||
export { default as cloudflare } from './cloudflare';
|
||||
|
@ -7,6 +8,7 @@ export { default as deleteaccount } from './deleteaccount';
|
|||
export { default as emailcode } from './emailcode';
|
||||
export { default as eval } from './eval';
|
||||
export { default as exec } from './exec';
|
||||
export { default as getreferral } from './getreferral';
|
||||
export { default as help } from './help';
|
||||
export { default as info } from './info';
|
||||
export { default as limits } from './limits';
|
||||
|
|
|
@ -36,6 +36,7 @@ export default class Lock extends Command {
|
|||
this.client.util.transport.sendMail({
|
||||
to: account.emailAddress,
|
||||
from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>',
|
||||
replyTo: 'cloud-help@libraryofcode.org',
|
||||
subject: 'Your account has been locked',
|
||||
html: `
|
||||
<h1>Library of Code | Cloud Services</h1>
|
||||
|
|
|
@ -31,6 +31,7 @@ export default class Notify extends Command {
|
|||
this.client.util.transport.sendMail({
|
||||
to: account.emailAddress,
|
||||
from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>',
|
||||
replyTo: 'cloud-help@libraryofcode.org',
|
||||
subject: 'Notification',
|
||||
html: `
|
||||
<h1>Library of Code sp-us | Cloud Services</h1>
|
||||
|
|
|
@ -25,6 +25,7 @@ export default class Warn extends Command {
|
|||
return this.client.util.transport.sendMail({
|
||||
to: account.emailAddress,
|
||||
from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>',
|
||||
replyTo: 'cloud-help@libraryofcode.org',
|
||||
subject: 'Your account has been warned',
|
||||
html: `
|
||||
<h1>Library of Code sp-us | Cloud Services</h1>
|
||||
|
|
|
@ -84,6 +84,7 @@ export default class Whois extends Command {
|
|||
embed.addField('Email Address', account.emailAddress, true);
|
||||
embed.addField('Tier', String(account.tier), true);
|
||||
embed.addField('Support Key', account.supportKey, true);
|
||||
embed.addField('Referral Code & Total', `${account.referralCode} | ${account.totalReferrals}`, true);
|
||||
embed.addField('Created By', `<@${this.client.users.get(account.createdBy).id}>`, 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);
|
||||
|
|
Loading…
Reference in New Issue