diff --git a/src/commands/emailcode.ts b/src/commands/emailcode.ts new file mode 100644 index 0000000..ad203c1 --- /dev/null +++ b/src/commands/emailcode.ts @@ -0,0 +1,43 @@ +/* eslint-disable consistent-return */ +import { randomBytes } from 'crypto'; +import { Message } from 'eris'; +import { Client } from '..'; +import { Command, RichEmbed } from '../class'; + +export default class EmailCode extends Command { + constructor(client: Client) { + super(client); + this.name = 'emailcode'; + this.description = 'Sends a code to an email address to use for address verification.'; + this.usage = `${this.client.config.prefix}emailcode `; + this.permissions = { roles: ['446104438969466890'] }; + this.aliases = ['code']; + this.enabled = true; + } + + public async run(message: Message, args: string[]) { + try { + const code = randomBytes(5).toString('hex'); + if (!this.client.util.isValidEmail(args[0])) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid email address supplied.***`); + this.client.util.transport.sendMail({ + to: args[0], + from: 'Library of Code sp-us | Cloud Services ', + subject: 'Email Verification Code', + html: ` + + +

Library of Code | Cloud Services

+

Please provide the code provided below to the Staff member working with you on account creation.

+

${code}

+

Want to support us?

+

You can support us on Patreon! Head to our Patreon page and feel free to donate as much or as little as you want!
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!

+ Library of Code sp-us | Support Team + + `, + }); + message.channel.createMessage(`***${this.client.stores.emojis.success} Code: \`${code}\` | Email Address: ${args[0]}***`); + } catch (error) { + await this.client.util.handleError(error, message, this); + } + } +}