Updated handlers
This commit is contained in:
@@ -4,7 +4,6 @@ import fs from "fs"
|
||||
import { IModal } from "interfaces"
|
||||
import path from "path"
|
||||
import { ExtendedClient as Client } from "utils/Client.js"
|
||||
import { color } from "utils/functions/colors.js"
|
||||
import logToChannel from "utils/functions/logtochannel.js"
|
||||
type FileType = "js" | "ts"
|
||||
const __dirname = import.meta.dirname
|
||||
@@ -16,17 +15,7 @@ export default async function loadModalEvents(client: Client, ft: FileType) {
|
||||
for (const file of modalFiles) {
|
||||
const filePath = path.join(modalPath, file)
|
||||
const { default: modal } = await import("file://" + filePath) as { default: IModal }
|
||||
|
||||
if ("name" in modal && "execute" in modal) {
|
||||
client.modals.set(modal.name, modal)
|
||||
} else {
|
||||
console.log(
|
||||
color(
|
||||
`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`,
|
||||
"red"
|
||||
)
|
||||
)
|
||||
}
|
||||
client.modals.set(modal.name, modal)
|
||||
}
|
||||
|
||||
client.on(Events.InteractionCreate, async interaction => {
|
||||
@@ -35,6 +24,10 @@ export default async function loadModalEvents(client: Client, ft: FileType) {
|
||||
const modal = client.modals.get(interaction.customId)
|
||||
|
||||
if (!modal) {
|
||||
interaction.reply({
|
||||
content: "Modal logic not implemented. This is most likely an old modal",
|
||||
ephemeral: true
|
||||
})
|
||||
console.error(`No modal matching ${interaction.customId} was found.`)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user