mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Show how long a call lasted at the end
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const moment = require('moment');
|
||||
require('moment-duration-format');
|
||||
|
||||
module.exports = class PhoneInfoCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -28,7 +26,7 @@ module.exports = class PhoneInfoCommand extends Command {
|
||||
.addField('❯ Recipient Channel', `#${otherChannel.name}`, true)
|
||||
.addField('❯ Recipient Server', otherChannel.guild.name, 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('❯ Started By', call.startUser.tag, true);
|
||||
return msg.embed(embed);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "119.11.0",
|
||||
"version": "119.11.1",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
const { stripIndents } = require('common-tags');
|
||||
const moment = require('moment');
|
||||
require('moment-duration-format');
|
||||
const { shorten, stripInvites, verify } = require('../../util/Util');
|
||||
|
||||
module.exports = class PhoneCall {
|
||||
@@ -48,8 +50,8 @@ module.exports = class PhoneCall {
|
||||
this.active = false;
|
||||
clearTimeout(this.timeout);
|
||||
if (nonQuitter === 'time') {
|
||||
await this.origin.send('☎️ Call ended due to inactivity.');
|
||||
await this.recipient.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. _(Lasted ${this.durationDisplay})_`);
|
||||
} else if (nonQuitter === 'declined') {
|
||||
const canVoicemail = this.recipient.topic && !this.recipient.topic.includes('<xiao:phone:no-voicemail>');
|
||||
const recipientMsg = validation === 0
|
||||
@@ -81,8 +83,8 @@ module.exports = class PhoneCall {
|
||||
}
|
||||
} else {
|
||||
const quitter = nonQuitter.id === this.origin.id ? this.recipient : this.origin;
|
||||
await nonQuitter.send(`☎️ **${quitter.guild.name}** hung up.`);
|
||||
await quitter.send('☎️ Hung up.');
|
||||
await nonQuitter.send(`☎️ **${quitter.guild.name}** hung up. _(Lasted ${this.durationDisplay})_`);
|
||||
await quitter.send(`☎️ Hung up. _(Lasted ${this.durationDisplay})_`);
|
||||
}
|
||||
this.client.phone.delete(this.id);
|
||||
return this;
|
||||
@@ -134,4 +136,8 @@ module.exports = class PhoneCall {
|
||||
this.timeout = setTimeout(() => this.hangup('time'), 60000);
|
||||
return this.timeout;
|
||||
}
|
||||
|
||||
get durationDisplay() {
|
||||
return moment.duration(Date.now() - this.timeStarted).format('hh[h]mm[m]ss[s]');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user