From 410ad5fba2f9c33751f79637545fc1dac1035124 Mon Sep 17 00:00:00 2001 From: Taken Date: Sun, 1 Oct 2023 16:57:26 +0200 Subject: [PATCH] Updated the apllications to check for left users Signed-off-by: Taken --- events/buttons/guildapplicationdeny.js | 6 ---- events/modals/denyreasonbox.js | 42 +++++++++++++++++--------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/events/buttons/guildapplicationdeny.js b/events/buttons/guildapplicationdeny.js index da9f174..8c51b3e 100644 --- a/events/buttons/guildapplicationdeny.js +++ b/events/buttons/guildapplicationdeny.js @@ -8,12 +8,6 @@ module.exports = { async execute(interaction) { - const channel = interaction.channel; - const guild = interaction.guild; - const embedColor = Number(color.replace("#", "0x")); - - const message = interaction.message; - const modal = new ModalBuilder() .setTitle('Deny Reason') .setCustomId('denyreasonbox') diff --git a/events/modals/denyreasonbox.js b/events/modals/denyreasonbox.js index b406e86..854cc73 100644 --- a/events/modals/denyreasonbox.js +++ b/events/modals/denyreasonbox.js @@ -26,7 +26,6 @@ module.exports = { const applicant = await guild.members.fetch(applicantId); const reason = interaction.fields.fields.get('denyreason').value || "No reason provided"; const embedColor = Number(color.replace("#", "0x")); - const filePath = path.join(__dirname, `../../apps/guild/${applicantId}`); await message.edit({ components: [ @@ -55,24 +54,37 @@ module.exports = { "**Reason:** `" + reason + "`") .setColor(embedColor); - await applicant.send({ embeds: [dmMessage] }); + const missingUser = new EmbedBuilder() + .setDescription("[WARN] User has left the server and cannot be notified.") + .setColor(embedColor) + + const responseEmbed = new EmbedBuilder() + .setTitle("Application Denied") + .setDescription("The application has been denied by <@" + interaction.user.id + ">.\n" + + "**Reason:** `" + reason + "`") + .setColor(embedColor) + .setThumbnail({ + url: applicant.avatarURL() + }) + .setFooter({ + iconURL: guild.iconURL(), + text: "ID: " + applicant.id + }) + + if (applicant) { + await applicant.send({ embeds: [dmMessage] }); + } + + if (!applicant) { + var responseEmbeds = [responseEmbed, missingUser]; + } else { + var responseEmbeds = [responseEmbed]; + } await guildapp.findOneAndDelete({ userID: applicantId }); await interaction.editReply({ - embeds: [{ - title: "Application Denied", - description: "The application has been denied by <@" + interaction.user.id + ">.\n" + - "**Reason:** `" + reason + "`", - color: embedColor, - thumbnail: { - url: applicant.avatarURL() - }, - footer: { - iconURL: guild.iconURL(), - text: "ID: " + applicant.id - } - }], + embeds: responseEmbeds }); } }