Allow getting phone count even in non-marked channels

This commit is contained in:
Dragon Fire
2020-03-19 12:53:53 -04:00
parent 8fa5ee817e
commit af6932d6b2
+6 -4
View File
@@ -19,7 +19,8 @@ module.exports = class PhoneCommand extends Command {
validate: channelID => {
if (channelID.toLowerCase() === 'count') return true;
return /^[0-9]+$/.test(channelID);
}
},
parse: channelID => channelID.toLowerCase()
}
],
credit: [
@@ -33,10 +34,11 @@ module.exports = class PhoneCommand extends Command {
}
async run(msg, { channelID }) {
if (!msg.channel.topic || !msg.channel.topic.includes('<xiao:phone>')) {
if (channelID !== 'count' && !msg.channel.topic || !msg.channel.topic.includes('<xiao:phone>')) {
return msg.say('You can only start a call in a channel with `<xiao:phone>` in the topic.');
}
if (this.client.phone.some(call => [call.origin.id, call.recipient.id].includes(msg.channel.id))) {
const inCall = this.client.phone.some(call => [call.origin.id, call.recipient.id].includes(msg.channel.id));
if (channelID !== 'count' && inCall) {
return msg.say('This channel is already in a phone call.');
}
const channels = this.client.channels.cache.filter(channel => channel.type === 'text'
@@ -46,7 +48,7 @@ module.exports = class PhoneCommand extends Command {
if (!channels.size) return msg.reply('No channels currently allow phone calls...');
let channel;
if (channelID) {
if (channelID.toLowerCase() === 'count') return msg.say(`☎️ **${channels.size}** currently open lines.`);
if (channelID === 'count') return msg.say(`☎️ **${channels.size}** currently open lines.`);
channel = this.client.channels.cache.get(channelID);
if (!channel || channel.type !== 'text') return msg.reply('This channel does not exist.');
if (!channel.topic || !channel.topic.includes('<xiao:phone>')) {