From 13e56715c22d504e43200aa54484d02c25619db9 Mon Sep 17 00:00:00 2001 From: Taken Date: Sun, 1 Jun 2025 20:49:58 +0200 Subject: [PATCH] Updated guild application accept --- .../buttons/guildapplicationaccept.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/buttons/guildapplicationaccept.ts b/src/components/buttons/guildapplicationaccept.ts index 8f18063..c220a54 100644 --- a/src/components/buttons/guildapplicationaccept.ts +++ b/src/components/buttons/guildapplicationaccept.ts @@ -1,5 +1,5 @@ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, TextChannel } from "discord.js" -import { getGuildApp, removeVerify } from "src/drizzle/functions" +import { getGuildApp, removeGuildApp } from "src/drizzle/functions" import { addWaitingList, getWaitingLists, removeWaitingList } from "src/drizzle/functions" import { embedColor, hypixelGuildID, waitingListChannel, waitingListMessage } from "~/config/options" import { waitingListRole } from "~/config/roles" @@ -21,8 +21,8 @@ export default { const embed = message.embeds[0] const applicantId = embed.footer!.text.split(" ")[1] - const applicant = await guild.members.fetch(applicantId) - const applicantUsername = applicant.user.username + const [, applicant] = await tryCatch(guild.members.fetch(applicantId)) + const applicantUsername = applicant?.user.username await message.edit({ components: [ @@ -46,6 +46,17 @@ export default { ] }) + if (!applicant) { + await interaction.editReply({ + embeds: [{ + description: "Aplication has left the server and cannot be notified.", + color: embedColor + }] + }) + await removeGuildApp({ userID: applicantId }) + return + } + await applicant.send({ embeds: [{ description: "Your application for the Illegitimate guild has been accepted.\n\n" + @@ -64,8 +75,8 @@ export default { timestamp: time }) + await removeGuildApp({ userID: applicantId, uuid: applicantUUID }) await applicant.roles.add(waitingListRole) - await removeVerify({ userID: applicantId }) await interaction.editReply({ embeds: [{