Added null safety for missing user
This commit is contained in:
@@ -10,20 +10,13 @@ module.exports = {
|
|||||||
/** @param { import('discord.js').ModalSubmitInteraction } interaction */
|
/** @param { import('discord.js').ModalSubmitInteraction } interaction */
|
||||||
|
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
interaction.deferReply()
|
await interaction.deferReply()
|
||||||
|
|
||||||
const guild = interaction.guild
|
const guild = interaction.guild
|
||||||
|
|
||||||
const message = interaction.message
|
const message = interaction.message
|
||||||
const embed = message.embeds[0]
|
const embed = message.embeds[0]
|
||||||
const applicantId = embed.footer.text.split(" ")[1]
|
const applicantId = embed.footer.text.split(" ")[1]
|
||||||
|
|
||||||
let applicant = ""
|
|
||||||
try {
|
|
||||||
applicant = await guild.members.fetch(applicantId)
|
|
||||||
} catch (error) {
|
|
||||||
applicant = null
|
|
||||||
}
|
|
||||||
const reason = interaction.fields.fields.get("denyreason").value || "No reason provided"
|
const reason = interaction.fields.fields.get("denyreason").value || "No reason provided"
|
||||||
const embedColor = Number(color.replace("#", "0x"))
|
const embedColor = Number(color.replace("#", "0x"))
|
||||||
|
|
||||||
@@ -49,6 +42,13 @@ module.exports = {
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let applicant = ""
|
||||||
|
try {
|
||||||
|
applicant = await guild.members.fetch(applicantId)
|
||||||
|
} catch (error) {
|
||||||
|
applicant = null
|
||||||
|
}
|
||||||
|
|
||||||
const dmMessage = new EmbedBuilder()
|
const dmMessage = new EmbedBuilder()
|
||||||
.setDescription("Your application for the Illegitimate guild has been denied\n" +
|
.setDescription("Your application for the Illegitimate guild has been denied\n" +
|
||||||
"**Reason:** `" + reason + "`")
|
"**Reason:** `" + reason + "`")
|
||||||
@@ -66,7 +66,7 @@ module.exports = {
|
|||||||
.setThumbnail(guild.iconURL())
|
.setThumbnail(guild.iconURL())
|
||||||
.setFooter({
|
.setFooter({
|
||||||
iconURL: guild.iconURL(),
|
iconURL: guild.iconURL(),
|
||||||
text: "ID: " + applicant.id
|
text: "ID: " + applicantId
|
||||||
})
|
})
|
||||||
|
|
||||||
if (applicant !== null) {
|
if (applicant !== null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user