import { Message } from 'discord.js'; 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', 'gr']; this.enabled = true; } public async run(message: Message, args: string[]) { try { 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.users.fetch(message.author.id).then((u) => { u.send(`__**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); } } }