add promo commands
parent
5a7c3d7fdb
commit
8ce7f51f8d
|
@ -0,0 +1,33 @@
|
|||
import { Message } from 'eris';
|
||||
import { Client, 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 <stripe PC API id>`;
|
||||
this.aliases = ['promo', 'ap'];
|
||||
this.permissions = 6;
|
||||
this.guildOnly = true;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
try {
|
||||
const pcd = await this.client.stripe.promotionCodes.retrieve(args[0]);
|
||||
const promo = new this.client.db.Promo({
|
||||
code: pcd.code,
|
||||
pID: args[0],
|
||||
});
|
||||
await promo.save();
|
||||
} catch (err) {
|
||||
return this.error(message.channel, 'Promotional API ID doesn\'t exist.');
|
||||
}
|
||||
} catch (err) {
|
||||
return this.client.util.handleError(err, message, this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
import { Message } from 'eris';
|
||||
import { Client, Command } from '../class';
|
||||
|
||||
export default class DeletePromoCode extends Command {
|
||||
constructor(client: Client) {
|
||||
super(client);
|
||||
this.name = 'delpromo';
|
||||
this.description = 'Deletes a promotional code for Stripe.';
|
||||
this.usage = `${this.client.config.prefix}delpromo <stripe PC API id>`;
|
||||
this.aliases = ['dp'];
|
||||
this.permissions = 6;
|
||||
this.guildOnly = true;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
try {
|
||||
await this.client.stripe.promotionCodes.retrieve(args[0]);
|
||||
await this.client.db.Promo.deleteOne({ pID: args[0] }).lean().exec();
|
||||
} catch (err) {
|
||||
return this.error(message.channel, 'Promotional API ID doesn\'t exist.');
|
||||
}
|
||||
} catch (err) {
|
||||
return this.client.util.handleError(err, message, this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
export { default as additem } from './additem';
|
||||
export { default as addmerchant } from './addmerchant';
|
||||
export { default as addnote } from './addnote';
|
||||
export { default as addpromo } from './addpromo';
|
||||
export { default as addrank } from './addrank';
|
||||
export { default as addredirect } from './addredirect';
|
||||
export { default as apply } from './apply';
|
||||
|
@ -10,6 +11,7 @@ export { default as callback } from './callback';
|
|||
export { default as delitem } from './delitem';
|
||||
export { default as delmerchant } from './delmerchant';
|
||||
export { default as delnote } from './delnote';
|
||||
export { default as delpromo } from './delpromo';
|
||||
export { default as delrank } from './delrank';
|
||||
export { default as delredirect } from './delredirect';
|
||||
export { default as djs } from './djs';
|
||||
|
|
Loading…
Reference in New Issue