1
0
Fork 0
cloudservices/src/commands/getreferral.ts

28 lines
1.3 KiB
TypeScript

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);
}
}
}