mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Fix
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user