Files
xiao/commands/portal/fix-portal-channels.js
T
2018-02-18 15:58:42 +00:00

25 lines
688 B
JavaScript

const { Command } = require('discord.js-commando');
module.exports = class FixPortalChannelsCommand extends Command {
constructor(client) {
super(client, {
name: 'fix-portal-channels',
group: 'portal',
memberName: 'fix-portal-channels',
description: 'Removes no longer existent channels from the portal list.',
ownerOnly: true
});
}
run(msg) {
const channels = this.client.provider.get('global', 'portals', []);
let count = 0;
for (const channel of channels) {
if (this.client.channels.has(channel)) continue;
channels.splice(channels.indexOf(channel), 1);
count++;
}
return msg.say(`Cleared **${count}** channels from the portal list.`);
}
};