Added error log channel

This commit is contained in:
2023-12-31 18:14:29 +01:00
parent 7bc1b606d3
commit ad266ef97c
6 changed files with 97 additions and 5 deletions

View File

@@ -1,9 +1,11 @@
import { ExtendedClient as Client } from "../Client"
import { errorLogChannel, color } from "../../../config/options.json"
import { Modal } from "../../interfaces"
import { Events } from "discord.js"
import { Events, GuildTextBasedChannel } from "discord.js"
import path = require("path")
import fs = require("fs")
import { FileType } from "../../typings"
const embedColor = Number(color.replace("#", "0x"))
export default function loadModalEvents(client: Client, ft: FileType) {
const modalPath = path.join(__dirname, "..", "..", "events", "modals")
@@ -40,6 +42,22 @@ export default function loadModalEvents(client: Client, ft: FileType) {
await modal.execute(interaction)
} catch (error) {
console.error(error)
const channel = client.channels.cache.get(errorLogChannel) as GuildTextBasedChannel
if (!channel) {
console.log("No error log channel found.")
}
await channel.send({
embeds: [{
title: "Button error occured",
description: String(error),
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL({ forceStatic: false })!,
text: interaction.user.username + " | " + interaction.customId
}
}],
})
await interaction.reply({
content: "There was an error while executing this modal!",
ephemeral: true,