import { Client, CmdContext, Command } from '../class'; export default class AddPromoCode extends Command { constructor(client: Client) { super(client); this.name = 'addpromo'; this.description = 'Creates a new promotional code for Stripe.'; this.usage = `${this.client.config.prefix}addpromo `; this.aliases = ['promo', 'ap']; this.permissions = 6; this.guildOnly = true; this.enabled = true; } public async run(ctx: CmdContext) { if (!ctx.args[0]) return this.client.commands.get('help').run(new CmdContext(ctx.message, [this.name])); try { const pcd = await this.client.stripe.promotionCodes.retrieve(ctx.args[0]); const promo = new this.client.db.mongo.Promo({ code: pcd.code, pID: ctx.args[0], }); await promo.save(); } catch (err) { return this.error(ctx.message.channel, 'Promotional API ID doesn\'t exist.'); } } }