This commit is contained in:
Dragon Fire
2020-12-01 20:36:21 -05:00
parent 1407e9c4e1
commit df6ba6d24e
4 changed files with 7 additions and 5 deletions
+1
View File
@@ -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('<xiao:phone>')))) return;
if (!call.active) return;
if (call.adminCall && msg.guild.id === call.origin.guild.id && !client.isOwner(msg.author)) return;
+1 -1
View File
@@ -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;
+4 -3
View File
@@ -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('<xiao:phone>')) {
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;
+1 -1
View File
@@ -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;