From 32cfeb354e6552d38f94203860856743089c4778 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sat, 1 Feb 2025 19:15:12 -0700 Subject: [PATCH] Add PBX Role giver again --- interactionHandlers/common/createExt.js | 1 + interactionHandlers/common/getExtInfo.js | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/interactionHandlers/common/createExt.js b/interactionHandlers/common/createExt.js index 90123ea..99df27b 100644 --- a/interactionHandlers/common/createExt.js +++ b/interactionHandlers/common/createExt.js @@ -29,6 +29,7 @@ module.exports.execute = async (interaction) => { description: `**PBX Address:** \`${process.env.PBX_HOSTNAME}\`\n**Extension:** \`${extInfo.fetchExtension.user.extension}\`\n**Name:** \`${extInfo.fetchExtension.user.name}\`\n**Password:** ||\`${extInfo.fetchExtension.user.extPassword}\`||`, color: 0x00ff00 }], ephemeral: true }) + if (process.env.EXTENSION_ROLE_ID) await interaction.member.roles.add(process.env.EXTENSION_ROLE_ID); }).catch(async (error) => { log.error(error); await interaction.editReply({ content: 'There was an error while creating your extension!', ephemeral: true }); diff --git a/interactionHandlers/common/getExtInfo.js b/interactionHandlers/common/getExtInfo.js index 3c7ae18..16f612d 100644 --- a/interactionHandlers/common/getExtInfo.js +++ b/interactionHandlers/common/getExtInfo.js @@ -12,7 +12,7 @@ module.exports.execute = async (interaction) => { return; } const extInfo = await fpbx.getExtension(lookup.extension); - return await interaction.reply({ + await interaction.reply({ ephemeral: true, embeds: [ { title: "Your Extension Info", @@ -22,4 +22,12 @@ module.exports.execute = async (interaction) => { ] }); + 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); + } + } + } \ No newline at end of file