mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 22:32:50 +02:00
Fix some phone bugs
This commit is contained in:
@@ -62,9 +62,10 @@ client.on('message', async msg => {
|
|||||||
const origin = client.phone.find(call => call.origin.id === msg.channel.id);
|
const origin = client.phone.find(call => call.origin.id === msg.channel.id);
|
||||||
const recipient = client.phone.find(call => call.recipient.id === msg.channel.id);
|
const recipient = client.phone.find(call => call.recipient.id === msg.channel.id);
|
||||||
if (!origin && !recipient) return;
|
if (!origin && !recipient) return;
|
||||||
|
const call = origin || recipient;
|
||||||
|
if (!call.active) return;
|
||||||
try {
|
try {
|
||||||
if (origin) await origin.send(origin.recipient, msg);
|
await call.send(origin ? call.recipient : call.origin, msg);
|
||||||
if (recipient) await recipient.send(recipient.origin, msg);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return; // eslint-disable-line no-useless-return
|
return; // eslint-disable-line no-useless-return
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "110.10.0",
|
"version": "110.10.1",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -32,19 +32,22 @@ module.exports = class PhoneCall {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async decline(validation) {
|
async decline(validation) {
|
||||||
const directMsg = validation === 0 ? 'didn\'t answer...' : 'declined the call...';
|
|
||||||
this.client.phone.delete(this.id);
|
this.client.phone.delete(this.id);
|
||||||
await this.origin.send(`☎️ **${this.recipient.guild.name}** ${directMsg}`);
|
await this.hangup('declined', validation);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
async hangup(nonQuitter) {
|
async hangup(nonQuitter, validation) {
|
||||||
this.active = false;
|
this.active = false;
|
||||||
clearTimeout(this.timeout);
|
clearTimeout(this.timeout);
|
||||||
this.client.phone.delete(this.id);
|
this.client.phone.delete(this.id);
|
||||||
if (nonQuitter === 'time') {
|
if (nonQuitter === 'time') {
|
||||||
await this.origin.send('☎️ Call ended due to inactivity.');
|
await this.origin.send('☎️ Call ended due to inactivity.');
|
||||||
await this.recipient.send('☎️ Call ended due to inactivity.');
|
await this.recipient.send('☎️ Call ended due to inactivity.');
|
||||||
|
} else if (nonQuitter === 'declined') {
|
||||||
|
const directMsg = validation === 0 ? 'didn\'t answer...' : 'declined the call...';
|
||||||
|
await this.origin.send(`☎️ **${this.recipient.guild.name}** ${directMsg}`);
|
||||||
|
await this.recipient.send('☎️ Declined the call.');
|
||||||
} else {
|
} else {
|
||||||
const quitter = nonQuitter.id === this.origin.id ? this.recipient : this.origin;
|
const quitter = nonQuitter.id === this.origin.id ? this.recipient : this.origin;
|
||||||
await nonQuitter.send(`☎️ **${quitter.guild.name}** hung up.`);
|
await nonQuitter.send(`☎️ **${quitter.guild.name}** hung up.`);
|
||||||
|
|||||||
Reference in New Issue
Block a user