From df6ba6d24e45b43060a0992252244683e0ed99f2 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Tue, 1 Dec 2020 20:36:21 -0500 Subject: [PATCH] Fix --- Xiao.js | 1 + commands/phone/admin-phone.js | 2 +- commands/phone/phone.js | 7 ++++--- structures/phone/PhoneCall.js | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Xiao.js b/Xiao.js index 287e5d80..1d085194 100644 --- a/Xiao.js +++ b/Xiao.js @@ -110,6 +110,7 @@ client.on('message', async msg => { const recipient = client.phone.find(call => call.recipient.id === msg.channel.id); if (!origin && !recipient) return; const call = origin || recipient; + if (call.originDM && call.startUser.id !== msg.author.id) return; if (!call.adminCall && (msg.guild && (!msg.channel.topic || !msg.channel.topic.includes('')))) return; if (!call.active) return; if (call.adminCall && msg.guild.id === call.origin.guild.id && !client.isOwner(msg.author)) return; diff --git a/commands/phone/admin-phone.js b/commands/phone/admin-phone.js index e18a31c3..8d6e00bc 100644 --- a/commands/phone/admin-phone.js +++ b/commands/phone/admin-phone.js @@ -27,7 +27,7 @@ module.exports = class AdminPhoneCommand extends Command { const channel = this.client.channels.cache.get(channelID); if (!channel || !channel.guild) return msg.reply('This channel does not exist.'); try { - const id = `${msg.channel.id}:${channel.id}`; + 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, true)); await this.client.phone.get(id).start(); return null; diff --git a/commands/phone/phone.js b/commands/phone/phone.js index fb37229a..7f5b327a 100644 --- a/commands/phone/phone.js +++ b/commands/phone/phone.js @@ -58,8 +58,9 @@ module.exports = class PhoneCommand extends Command { if (channelID) { if (channelID === 'count') return msg.say(`☎️ **${channels.size}** currently open lines.`); channel = this.client.channels.cache.get(channelID); - if (!channel) return msg.reply('This channel does not exist.'); - if (!channel.guild) return msg.reply('You cannot call DM channels.'); + 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('This channel does not exist.'); if (!channel.topic || !channel.topic.includes('')) { return msg.reply('This channel does not allow phone calls.'); } @@ -74,7 +75,7 @@ module.exports = class PhoneCommand extends Command { channel = channels.random(); } try { - const id = `${msg.channel.id}:${channel.id}`; + 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)); await this.client.phone.get(id).start(); return null; diff --git a/structures/phone/PhoneCall.js b/structures/phone/PhoneCall.js index 48ba523e..519671b0 100644 --- a/structures/phone/PhoneCall.js +++ b/structures/phone/PhoneCall.js @@ -7,7 +7,7 @@ module.exports = class PhoneCall { constructor(client, startUser, origin, recipient, adminCall) { Object.defineProperty(this, 'client', { value: client }); - this.id = `${origin.id}:${recipient.id}`; + this.id = `${origin.guild ? origin.id : startUser.id}:${recipient.id}`; this.origin = origin; this.originDM = !origin.guild; this.recipient = recipient;