48 lines
1.4 KiB
JavaScript
48 lines
1.4 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
|
|
}
|
|
],
|
|
components: [
|
|
{
|
|
type: 1,
|
|
components: [
|
|
{
|
|
type: Discord.ComponentType.Button,
|
|
label: "Reset Password",
|
|
emoji: "🔄",
|
|
style: Discord.ButtonStyle.Danger,
|
|
custom_id: "resetPassword"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
});
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
} |