From 4f2a283f31b22fa926bfb9be0a1863d3d03a6e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A7=81Ash=C3=BB=EA=A7=82?= <30575805+Ashu11-A@users.noreply.github.com> Date: Thu, 13 Jun 2024 23:09:04 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Check=20URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/tickets/src/class/TemplateBuilder.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/tickets/src/class/TemplateBuilder.ts b/plugins/tickets/src/class/TemplateBuilder.ts index 142e5dd6..101e3cf2 100644 --- a/plugins/tickets/src/class/TemplateBuilder.ts +++ b/plugins/tickets/src/class/TemplateBuilder.ts @@ -4,6 +4,7 @@ import TemplateTable from "@/entity/Template.entry.js"; import { EmbedBuilder } from "@discordjs/builders"; import { APIEmbed as APIEmbedDiscord, ButtonInteraction, CacheType, Colors, CommandInteraction, MessageComponentInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from "discord.js"; import { TemplateButtonBuilder } from "./TemplateButtonBuilder.js"; +import { checkURL } from "@/functions/checker.js"; const database = new Database({ table: 'Template' }) @@ -73,9 +74,22 @@ export class TemplateBuilder { return } + const [isImageURL] = checkURL(this.options.image) + const [isThumbURL] = checkURL(this.options.thumbnail) + + if (this.options.image !== '' && !isImageURL) { + await new Error({ element: 'Image', interaction: this.interaction }).invalidProperty().reply() + return + } + + if (this.options.thumbnail !== '' && !isThumbURL) { + await new Error({ element: 'Thumbnail', interaction: this.interaction }).invalidProperty().reply() + return + } + const embed = this.render(templateData.embed) const components = buttonBuilder - .setMode(this.mode) + .setMode(this.mode ?? 'production') .setProperties(templateData.properties) .setSelects(templateData.selects) .setType(templateData.type)