mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Voicemail System
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "114.16.2",
|
||||
"version": "114.16.3",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user