discord-freepbx-manager/interactionHandlers/common/getExtInfo.js
Christopher Cookman 68d6402ffd - Disable unfinished CDR commands
- Impliment delayed auto-delete of orphaned extensions, with auto cancel.
2025-02-11 08:28:41 -07:00

34 lines
1.2 KiB
JavaScript

const pool = global.pool
const fpbx = global.fpbx
const client = global.client
const log = global.log
module.exports = {};
module.exports.execute = async (interaction) => {
const [lookup] = await pool.query('SELECT * FROM discord_users WHERE discordId = ?', [interaction.user.id]);
if (!lookup) {
await interaction.reply({ content: `We're sorry, It doesn't look like you have an extension!`, ephemeral: true });
return;
}
await interaction.deferReply({ ephemeral: true });
const extInfo = await fpbx.getExtension(lookup.extension);
await interaction.editReply({
ephemeral: true, embeds: [
{
title: "Your Extension Info",
description: `**PBX Address:** \`${process.env.PBX_HOSTNAME}\`\n**Extension/Username:** \`${extInfo.fetchExtension.user.extension}\`\n**Name:** \`${extInfo.fetchExtension.user.name}\`\n**Password:** ||\`${extInfo.fetchExtension.user.extPassword}\`||`,
color: 0x00ff00
}
]
});
const EXTENSION_ROLE_ID = process.env.EXTENSION_ROLE_ID;
if (EXTENSION_ROLE_ID) {
const member = await interaction.guild.members.fetch(interaction.user.id);
if (!member.roles.cache.has(EXTENSION_ROLE_ID)) {
await member.roles.add(EXTENSION_ROLE_ID);
}
}
}