community-relations/src/commands/delmerchant.ts

28 lines
985 B
TypeScript
Raw Normal View History

2020-09-29 02:43:59 -04:00
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);
}
}
}