mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
No direct calling
This commit is contained in:
+9
-29
@@ -15,15 +15,11 @@ module.exports = class PhoneCommand extends Command {
|
||||
},
|
||||
args: [
|
||||
{
|
||||
key: 'channelID',
|
||||
prompt: 'What channel would you like to start a call with?',
|
||||
key: 'count',
|
||||
prompt: 'Do you want to get the count of phone servers?',
|
||||
type: 'string',
|
||||
default: '',
|
||||
validate: channelID => {
|
||||
if (channelID.toLowerCase() === 'count') return true;
|
||||
return /^[0-9]+$/.test(channelID);
|
||||
},
|
||||
parse: channelID => channelID.toLowerCase()
|
||||
parse: count => count.toLowerCase()
|
||||
}
|
||||
],
|
||||
credit: [
|
||||
@@ -36,11 +32,11 @@ module.exports = class PhoneCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { channelID }) {
|
||||
if (channelID !== 'count' && (msg.guild && (!msg.channel.topic || !msg.channel.topic.includes('<xiao:phone>')))) {
|
||||
async run(msg, { count }) {
|
||||
if (count !== 'count' && (msg.guild && (!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 (channelID !== 'count' && this.client.phone.inCall(msg.channel)) {
|
||||
if (count !== 'count' && this.client.phone.inCall(msg.channel)) {
|
||||
return msg.say('This channel is already in a phone call.');
|
||||
}
|
||||
const channels = this.client.channels.cache.filter(channel => channel.guild
|
||||
@@ -49,26 +45,10 @@ module.exports = class PhoneCommand extends Command {
|
||||
&& !channel.topic.includes('<xiao:phone:no-random>')
|
||||
&& !this.client.phone.isBlocked(msg.channel, channel, msg.author)
|
||||
&& (msg.guild ? !msg.guild.channels.cache.has(channel.id) : true)
|
||||
&& (channelID ? true : !this.client.phone.inCall(channel)));
|
||||
&& !this.client.phone.inCall(channel));
|
||||
if (count === 'count') return msg.say(`☎️ **${channels.size}** currently open lines.`);
|
||||
if (!channels.size) return msg.reply('No channels currently allow phone calls...');
|
||||
let channel;
|
||||
if (channelID) {
|
||||
if (channelID === 'count') return msg.say(`☎️ **${channels.size}** currently open lines.`);
|
||||
channel = this.client.channels.cache.get(channelID);
|
||||
const user = this.client.users.cache.get(channelID);
|
||||
if (user) return msg.reply('You cannot call DM channels.');
|
||||
if (!channel || !channel.guild) return msg.reply('That channel does not exist.');
|
||||
if (!channel.topic || !channel.topic.includes('<xiao:phone>')) {
|
||||
return msg.reply('That channel does not allow phone calls.');
|
||||
}
|
||||
if (msg.channel.id === channel.id) return msg.reply('You are literally in that channel right now.');
|
||||
if (this.client.phone.inCall(channel)) return msg.reply('That channel is already in a call.');
|
||||
if (this.client.phone.isBlocked(msg.channel, channel, msg.author)) {
|
||||
return msg.reply('That channel has blocked this channel from calling them.');
|
||||
}
|
||||
} else {
|
||||
channel = channels.random();
|
||||
}
|
||||
const channel = channels.random();
|
||||
try {
|
||||
const id = `${msg.guild ? msg.channel.id : msg.author.id}:${channel.id}`;
|
||||
this.client.phone.set(id, new PhoneCall(this.client, msg.author, msg.channel, channel));
|
||||
|
||||
Reference in New Issue
Block a user