mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 22:44:32 +02:00
Allow getting phone count even in non-marked channels
This commit is contained in:
@@ -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>')) {
|
||||
|
||||
Reference in New Issue
Block a user