Voicemail System

This commit is contained in:
Dragon Fire
2020-05-19 14:01:26 -04:00
parent 92c31cde12
commit 0c04ae9013
4 changed files with 35 additions and 4 deletions
+1
View File
@@ -218,6 +218,7 @@ in the appropriate channel's topic to use it.
* `<xiao:disable-leave>` Disables leave messages (Place in the channel you recieve welcome messages in).
* `<xiao:phone>` Allows a channel to recieve phone calls from the `phone` command.
* `<xiao:phone:no-voicemail>` Prevents this channel from recieving voicemails for missed calls.
* `<xiao:phone-book:hide>` Hides a channel from the `phone-book` command.
* `<xiao:portal>` Allows a channel to recieve portal messages from the `portal-send` command.
+1
View File
@@ -20,6 +20,7 @@ module.exports = class OptionsCommand extends Command {
\`<xiao:disable-leave>\` Disables leave messages (System Channel).
\`<xiao:phone>\` Allows this channel to recieve phone calls.
\`<xiao:phone:no-voicemail>\` Prevents this channel from recieving voicemails for missed calls.
\`<xiao:phone-book:hide>\` Hides this channel from \`phone-book\`.
\`<xiao:portal>\` Marks the channel as a portal channel for \`portal-send\`.
`);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "114.16.2",
"version": "114.16.3",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {
+32 -3
View File
@@ -47,10 +47,31 @@ module.exports = class PhoneCall {
await this.origin.send('☎️ Call ended due to inactivity.');
await this.recipient.send('☎️ Call ended due to inactivity.');
} else if (nonQuitter === 'declined') {
const originMsg = validation === 0 ? 'didn\'t answer...' : 'declined the call...';
const recipientMsg = validation === 0 ? 'Sent to voicemail (not really).' : 'Declined the call.';
await this.origin.send(`☎️ **${this.recipient.guild.name}** ${originMsg}`);
const recipientMsg = validation === 0 ? 'Sent to voicemail.' : 'Declined the call.';
await this.recipient.send(`☎️ ${recipientMsg}`);
if (validation === 0 && channel.topic && !channel.topic.includes('<xiao:phone:no-voicemail>')) {
await this.origin.send(`☎️ **${this.recipient.guild.name}** didn't answer... Leave a voicemail?`);
const voicemailValidation = await verify(this.origin, null);
if (!voicemailValidation) {
await this.origin.send('☎️ No voicemail will be left.');
} else {
await this.origin.send('☎️ Please leave your message (max 280 characters) after the beep. _Beep_.');
const voicemail = await this.origin.awaitMessages(res => res.content && res.content.length >= 280, {
time: 30000,
max: 1
});
if (!voicemail.size) {
await this.origin.send('☎️ No voicemail will be left.');
} else {
const voicemailMsg = voicemail.first();
await this.sendVoicemail(this.recipient, voicemailMsg.author, voicemailMsg.content);
await this.origin.send('☎️ Your voicemail has been left.');
}
}
} else {
let originMsg = validation === 0 ? 'didn\'t answer...' : 'declined the call...';
await this.origin.send(`☎️ **${this.recipient.guild.name}** ${originMsg}`);
}
} else {
const quitter = nonQuitter.id === this.origin.id ? this.recipient : this.origin;
await nonQuitter.send(`☎️ **${quitter.guild.name}** hung up.`);
@@ -83,6 +104,14 @@ module.exports = class PhoneCall {
return channel.send(`☎️ **${msg.author.tag}:** ${content}\n${attachments || ''}`.trim());
}
sendVoicemail(channel, author, message) {
if (!channel.topic || channel.topic.includes('<xiao:phone:no-voicemail>')) return null;
return channel.send(stripInvites`
☎️ New Voicemail from **${channel.guild.name}**:
**${author.tag}:** ${message}
`);
}
setTimeout() {
if (this.timeout) clearTimeout(this.timeout);
this.timeout = setTimeout(() => this.hangup('time'), 60000);