add commands to add/del merchants
parent
b9ebe73eaa
commit
8b0a2e7f93
|
@ -0,0 +1,31 @@
|
||||||
|
import { Message } from 'eris';
|
||||||
|
import { randomBytes } from 'crypto';
|
||||||
|
import { Client, Command } from '../class';
|
||||||
|
|
||||||
|
export default class AddMerchant extends Command {
|
||||||
|
constructor(client: Client) {
|
||||||
|
super(client);
|
||||||
|
this.name = 'addmerchant';
|
||||||
|
this.description = 'Creates a new merchant.';
|
||||||
|
this.usage = `${this.client.config.prefix}addmerchant <merchant name>`;
|
||||||
|
this.aliases = ['am'];
|
||||||
|
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]);
|
||||||
|
const key = randomBytes(20).toString('hex');
|
||||||
|
const merchant = await (new this.client.db.Merchant({
|
||||||
|
name: args.join(' '),
|
||||||
|
key,
|
||||||
|
pulls: [],
|
||||||
|
})).save();
|
||||||
|
return this.success(message.channel, `Created merchant (${merchant._id}). \`${args.join(' ')}\`\n\n\`${key}\``);
|
||||||
|
} catch (err) {
|
||||||
|
return this.client.util.handleError(err, message, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { Message } from 'eris';
|
||||||
|
import { randomBytes } from 'crypto';
|
||||||
|
import { Client, Command } from '../class';
|
||||||
|
|
||||||
|
export default class DelMerchant extends Command {
|
||||||
|
constructor(client: Client) {
|
||||||
|
super(client);
|
||||||
|
this.name = 'delmerchant';
|
||||||
|
this.description = 'Deletes a merchant.';
|
||||||
|
this.usage = `${this.client.config.prefix}delmerchant <merchant id>`;
|
||||||
|
this.aliases = ['dm'];
|
||||||
|
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]);
|
||||||
|
const merchant = await this.client.db.Merchant.findOne({ _id: args[0] });
|
||||||
|
if (!merchant) return this.error(message.channel, 'Merchant specified does not exist.');
|
||||||
|
return this.success(message.channel, `Deleted merchant \`${merchant._id}\`.`);
|
||||||
|
} catch (err) {
|
||||||
|
return this.client.util.handleError(err, message, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,11 @@
|
||||||
export { default as additem } from './additem';
|
export { default as additem } from './additem';
|
||||||
|
export { default as addmerchant } from './addmerchant';
|
||||||
export { default as addnote } from './addnote';
|
export { default as addnote } from './addnote';
|
||||||
export { default as addrank } from './addrank';
|
export { default as addrank } from './addrank';
|
||||||
export { default as addredirect } from './addredirect';
|
export { default as addredirect } from './addredirect';
|
||||||
export { default as ban } from './ban';
|
export { default as ban } from './ban';
|
||||||
export { default as delitem } from './delitem';
|
export { default as delitem } from './delitem';
|
||||||
|
export { default as delmerchant } from './delmerchant';
|
||||||
export { default as delnote } from './delnote';
|
export { default as delnote } from './delnote';
|
||||||
export { default as delrank } from './delrank';
|
export { default as delrank } from './delrank';
|
||||||
export { default as delredirect } from './delredirect';
|
export { default as delredirect } from './delredirect';
|
||||||
|
|
Loading…
Reference in New Issue