From a74600388628c2cd18cbeb413779ecb63ab0d61a Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 14 Feb 2021 09:36:21 -0500 Subject: [PATCH] Add auto-accept phone calls option --- README.md | 1 + commands/util-public/options.js | 1 + package.json | 2 +- structures/phone/PhoneCall.js | 16 +++++++++++++--- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c4945ce7..f107585d 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,7 @@ in the appropriate channel's topic to use it. * `` Disables leave messages (Place in the channel you recieve welcome messages in). * `` Allows a channel to recieve phone calls from the `phone` command. +* `` Automatically accepts all incoming phone calls. * `` Hides the abuse notice from phone call pick-ups. * `` Prevents this channel from recieving voicemails for missed calls. * `` Makes the channel only able to be called directly in the `phone` command, rather than be picked at random. diff --git a/commands/util-public/options.js b/commands/util-public/options.js index f565399e..8faecb74 100644 --- a/commands/util-public/options.js +++ b/commands/util-public/options.js @@ -23,6 +23,7 @@ module.exports = class OptionsCommand extends Command { __Phone Options__ \`\` Allows this channel to recieve phone calls. + \`\` Automatically accepts all incoming phone calls. \`\` Hides the abuse notice from phone call pick-ups. \`\` Prevents this channel from recieving voicemails for missed calls. \`\` Makes the channel only able to be called directly, rather than picked randomly. diff --git a/package.json b/package.json index f81ebfac..eccd550e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "129.7.0", + "version": "129.7.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/structures/phone/PhoneCall.js b/structures/phone/PhoneCall.js index 21482785..0d165cdf 100644 --- a/structures/phone/PhoneCall.js +++ b/structures/phone/PhoneCall.js @@ -30,6 +30,10 @@ module.exports = class PhoneCall { } } else { await this.origin.send(`☎️ Calling **${this.recipient.guild.name} (${this.recipient.id})**...`); + if (this.recipient.topic && this.recipient.topic.includes('')) { + await this.accept(); + return this; + } if (this.originDM) { await this.recipient.send( `☎️ Incoming call from **${this.startUser.tag}'s DM (${this.startUser.id})**. Pick up?` @@ -53,13 +57,19 @@ module.exports = class PhoneCall { this.setTimeout(); if (this.adminCall) return this; const usage = this.client.registry.commands.get('hang-up').usage(); - if (!this.origin.topic.includes('')) await this.sendNotice(this.origin); + if (this.originDM || (this.origin.topic && !this.origin.topic.includes(''))) { + await this.sendNotice(this.origin, this.originDM); + } await this.origin.send(`☎️ **${this.recipient.guild.name}** picked up! Use ${usage} to hang up.`); if (this.originDM) { - await this.sendNotice(this.recipient, true); + if (this.recipient.topic && !this.recipient.topic.includes('')) { + await this.sendNotice(this.recipient); + } await this.recipient.send(`☎️ Accepted call from **${this.startUser.tag}'s DM**. Use ${usage} to hang up.`); } else { - if (!this.recipient.topic.includes('')) await this.sendNotice(this.recipient); + if (this.recipient.topic && !this.recipient.topic.includes('')) { + await this.sendNotice(this.recipient); + } await this.recipient.send(`☎️ Accepted call from **${this.origin.guild.name}**. Use ${usage} to hang up.`); } return this;