27 lines
976 B
TypeScript
27 lines
976 B
TypeScript
import { Message } from 'eris';
|
|
import { Command, Client } from '../class';
|
|
|
|
export default class DelNote extends Command {
|
|
constructor(client: Client) {
|
|
super(client);
|
|
this.name = 'delnote';
|
|
this.description = 'Deletes a note.';
|
|
this.usage = `${this.client.config.prefix}delnote <note id>`;
|
|
this.permissions = 1;
|
|
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 note = await this.client.db.Note.findOne({ _id: args[0] }).lean().exec().catch(() => {});
|
|
if (!note) return this.error(message.channel, 'Could not locate that note.');
|
|
await this.client.db.Note.deleteOne({ _id: note._id });
|
|
return this.success(message.channel, `Note # \`${note._id}\` has been deleted.`);
|
|
} catch (err) {
|
|
return this.client.util.handleError(err, message, this);
|
|
}
|
|
}
|
|
}
|