Add PBX Role giver again

This commit is contained in:
Christopher Cookman 2025-02-01 19:15:12 -07:00
parent bb3e063987
commit 32cfeb354e
2 changed files with 10 additions and 1 deletions

View file

@ -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 });

View file

@ -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);
}
}
}