Added new tryCatch wrapper

This commit is contained in:
2025-03-20 23:41:18 +01:00
parent e555417e13
commit 95f9bb723f
16 changed files with 255 additions and 269 deletions

View File

@@ -4,6 +4,7 @@ import { addWaitingList, getWaitingLists, removeWaitingList } from "src/drizzle/
import { embedColor, hypixelGuildID, waitingListChannel, waitingListMessage } from "~/config/options"
import { waitingListRole } from "~/config/roles"
import { IButton } from "~/typings"
import tryCatch from "~/utils/Functions/trycatch"
import { getGuild, getIGN } from "~/utils/Hypixel"
import { log } from "~/utils/Logger"
@@ -82,7 +83,11 @@ export default {
})
if (process.env.NODE_ENV === "dev") return
try {
const [error] = await tryCatch(updateWaitingList())
if (error) return log("Error while trying to update waiting list.", "error")
async function updateWaitingList() {
const channel = guild.channels.cache.get(waitingListChannel) as TextChannel
const wlmessage = await channel!.messages.fetch(waitingListMessage)
@@ -125,12 +130,6 @@ export default {
timestamp: new Date().toISOString()
}]
})
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (err) {
log(
"Error while trying to update waiting list.",
"error"
)
}
}
} as IButton

View File

@@ -6,6 +6,7 @@ import { guild as guildQuestions } from "~/config/questions"
import { guildRole } from "~/config/roles"
import { IButton } from "~/typings"
import applicationQuestions from "~/utils/Functions/applicationquestions"
import tryCatch from "~/utils/Functions/trycatch"
export default {
name: "guildapply",
@@ -37,18 +38,16 @@ export default {
return
}
try {
await user.send({
embeds: [{
title: "Guild Application",
description: "If you wish to proceed with your application, please type `yes` otherwise type `cancel`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.",
color: embedColor
}]
})
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
const [error] = await tryCatch(user.send({
embeds: [{
title: "Guild Application",
description: "If you wish to proceed with your application, please type `yes` otherwise type `cancel`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.",
color: embedColor
}]
}))
if (error) {
await interaction.editReply("Please enable your DMs.")
return
}

View File

@@ -5,6 +5,7 @@ import { inactivity } from "~/config/questions"
import { beast, gm, guildRole, guildStaff, leader, member, staff } from "~/config/roles"
import { IButton } from "~/typings"
import applicationQuestions from "~/utils/Functions/applicationquestions"
import tryCatch from "~/utils/Functions/trycatch"
const guildRoles = [gm, leader, staff, beast, member, guildStaff, guildRole]
export default {
@@ -32,20 +33,18 @@ export default {
return inactivity[n - 1].r
}
try {
await user.send({
embeds: [{
title: "Guild Inactivity Log",
description: "Please answer the following questions to submit an inactivity log for the guild.\n" +
"If you wish to cancel your form, please press type `cancel` at any time.\n" +
"If you wish to proceed with your form, please type `yes`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.",
color: embedColor
}]
})
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
const [error] = await tryCatch(user.send({
embeds: [{
title: "Guild Inactivity Log",
description: "Please answer the following questions to submit an inactivity log for the guild.\n" +
"If you wish to cancel your form, please press type `cancel` at any time.\n" +
"If you wish to proceed with your form, please type `yes`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.",
color: embedColor
}]
}))
if (error) {
await interaction.reply({
content: "Please enable your DMs.",
flags: MessageFlags.Ephemeral

View File

@@ -7,6 +7,7 @@ import { guildRole, guildStaff } from "~/config/roles"
import { IButton } from "~/typings"
import env from "~/utils/Env"
import applicationQuestions from "~/utils/Functions/applicationquestions"
import tryCatch from "~/utils/Functions/trycatch"
export default {
name: "staffapply",
@@ -54,18 +55,16 @@ export default {
return
}
try {
await user.send({
embeds: [{
title: "Staff Application",
description: "If you wish to proceed with your application, please type `yes` otherwise type `cancel`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.",
color: embedColor
}]
})
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
const [error] = await tryCatch(user.send({
embeds: [{
title: "Staff Application",
description: "If you wish to proceed with your application, please type `yes` otherwise type `cancel`.\n\n" +
"**Do not upload images, videos, or GIFS.**\n" +
"You have a minute to respond to this message.",
color: embedColor
}]
}))
if (error) {
await interaction.editReply("Please enable your DMs.")
return
}

View File

@@ -1,7 +1,8 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, GuildMember, Message } from "discord.js"
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, Message } from "discord.js"
import { removeGuildApp } from "src/drizzle/functions"
import { embedColor } from "~/config/options"
import { IModal } from "~/typings"
import tryCatch from "~/utils/Functions/trycatch"
export default {
name: "denyreasonbox",
@@ -38,13 +39,7 @@ export default {
]
})
let applicant: GuildMember | null
try {
applicant = await guild.members.fetch(applicantId)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
applicant = null
}
const [, applicant] = await tryCatch(guild.members.fetch(applicantId))
const dmMessage = new EmbedBuilder()
.setDescription(