2020-07-06 03:15:06 -04:00
|
|
|
import { Message } from 'eris';
|
|
|
|
import { Client, Command } from '../class';
|
|
|
|
|
|
|
|
export default class DelRank extends Command {
|
|
|
|
constructor(client: Client) {
|
|
|
|
super(client);
|
|
|
|
this.name = 'delrank';
|
|
|
|
this.description = 'Deletes an existing self-assignable role. This doesn\'t delete the role itself.';
|
|
|
|
this.usage = `${this.client.config.prefix}delrank <role>`;
|
|
|
|
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]);
|
2020-07-09 04:41:29 -04:00
|
|
|
const role = this.client.util.resolveRole(args[0], this.mainGuild);
|
2020-07-06 03:15:06 -04:00
|
|
|
if (!role) return this.error(message.channel, 'The role you specified doesn\'t appear to exist.');
|
|
|
|
|
|
|
|
const check = await this.client.db.Rank.findOne({ roleID: role.id });
|
|
|
|
if (!check) return this.error(message.channel, 'The entry doesn\'t appear to exist.');
|
|
|
|
|
|
|
|
await this.client.db.Rank.deleteOne({ roleID: role.id });
|
|
|
|
return this.success(message.channel, `Role ${role.name} is no longer self-assignable.`);
|
|
|
|
} catch (err) {
|
|
|
|
return this.client.util.handleError(err, message, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|