Files
xiao/commands/phone/phone-info.js
T
2024-05-21 21:02:12 -04:00

35 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const Command = require('../../framework/Command');
const { EmbedBuilder } = require('discord.js');
module.exports = class PhoneInfoCommand extends Command {
constructor(client) {
super(client, {
name: 'phone-info',
aliases: ['call-info', 'phone-call-info'],
group: 'phone',
description: 'Gives information on the current phone call.'
});
}
run(msg) {
const origin = this.client.phone.find(call => call.origin.id === msg.channel.id);
const recipient = this.client.phone.find(call => call.recipient.id === msg.channel.id);
if (!origin && !recipient) return msg.reply('☎️ This channel is not in a phone call.');
const call = origin || recipient;
if (!call.active) return msg.reply('☎️ This call is not currently active.');
const otherChannel = msg.channel.id === call.origin.id ? call.recipient : call.origin;
const otherChannelDM = msg.channel.id === call.origin.id ? false : !call.origin.guild;
const embed = new EmbedBuilder()
.setColor(0x00AE86)
.setThumbnail(otherChannelDM
? call.startUser.displayAvatarURL({ extension: 'png' })
: otherChannel.guild.iconURL({ extension: 'png' }))
.addField(' Recipient Channel', otherChannelDM ? `@${call.startUser.tag}` : `#${otherChannel.name}`, true)
.addField(' Recipient Server', otherChannelDM ? 'DM' : otherChannel.guild.name, true)
.addField(' Recipient ID', otherChannel.id, true)
.addField(' Call Duration', call.durationDisplay, true)
.addField(' Started By', call.startUser.tag, true);
return msg.embed(embed);
}
};