Show how long a call lasted at the end

This commit is contained in:
Dragon Fire
2020-07-07 11:08:47 -04:00
parent 0b8b543cc9
commit 2b690f56ff
3 changed files with 12 additions and 8 deletions
+1 -3
View File
@@ -1,7 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
const moment = require('moment');
require('moment-duration-format');
module.exports = class PhoneInfoCommand extends Command { module.exports = class PhoneInfoCommand extends Command {
constructor(client) { constructor(client) {
@@ -28,7 +26,7 @@ module.exports = class PhoneInfoCommand extends Command {
.addField(' Recipient Channel', `#${otherChannel.name}`, true) .addField(' Recipient Channel', `#${otherChannel.name}`, true)
.addField(' Recipient Server', otherChannel.guild.name, true) .addField(' Recipient Server', otherChannel.guild.name, true)
.addField(' Recipient ID', otherChannel.id, true) .addField(' Recipient ID', otherChannel.id, true)
.addField(' Call Duration', moment.duration(Date.now() - call.timeStarted).format('hh[h]mm[m]ss[s]'), true) .addField(' Call Duration', call.durationDisplay, true)
.addField(' Admin Call?', call.ownerOrigin ? 'Yes' : 'No', true) .addField(' Admin Call?', call.ownerOrigin ? 'Yes' : 'No', true)
.addField(' Started By', call.startUser.tag, true); .addField(' Started By', call.startUser.tag, true);
return msg.embed(embed); return msg.embed(embed);
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xiao", "name": "xiao",
"version": "119.11.0", "version": "119.11.1",
"description": "Your personal server companion.", "description": "Your personal server companion.",
"main": "Xiao.js", "main": "Xiao.js",
"scripts": { "scripts": {
+10 -4
View File
@@ -1,4 +1,6 @@
const { stripIndents } = require('common-tags'); const { stripIndents } = require('common-tags');
const moment = require('moment');
require('moment-duration-format');
const { shorten, stripInvites, verify } = require('../../util/Util'); const { shorten, stripInvites, verify } = require('../../util/Util');
module.exports = class PhoneCall { module.exports = class PhoneCall {
@@ -48,8 +50,8 @@ module.exports = class PhoneCall {
this.active = false; this.active = false;
clearTimeout(this.timeout); clearTimeout(this.timeout);
if (nonQuitter === 'time') { if (nonQuitter === 'time') {
await this.origin.send('☎️ Call ended due to inactivity.'); await this.origin.send(`☎️ Call ended due to inactivity. _(Lasted ${this.durationDisplay})_`);
await this.recipient.send('☎️ Call ended due to inactivity.'); await this.recipient.send(`☎️ Call ended due to inactivity. _(Lasted ${this.durationDisplay})_`);
} else if (nonQuitter === 'declined') { } else if (nonQuitter === 'declined') {
const canVoicemail = this.recipient.topic && !this.recipient.topic.includes('<xiao:phone:no-voicemail>'); const canVoicemail = this.recipient.topic && !this.recipient.topic.includes('<xiao:phone:no-voicemail>');
const recipientMsg = validation === 0 const recipientMsg = validation === 0
@@ -81,8 +83,8 @@ module.exports = class PhoneCall {
} }
} 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. _(Lasted ${this.durationDisplay})_`);
await quitter.send('☎️ Hung up.'); await quitter.send(`☎️ Hung up. _(Lasted ${this.durationDisplay})_`);
} }
this.client.phone.delete(this.id); this.client.phone.delete(this.id);
return this; return this;
@@ -134,4 +136,8 @@ module.exports = class PhoneCall {
this.timeout = setTimeout(() => this.hangup('time'), 60000); this.timeout = setTimeout(() => this.hangup('time'), 60000);
return this.timeout; return this.timeout;
} }
get durationDisplay() {
return moment.duration(Date.now() - this.timeStarted).format('hh[h]mm[m]ss[s]');
}
}; };