Skip to content

Commit

Permalink
✅ Check URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu11-A committed Jun 14, 2024
1 parent 5cd0c3f commit 4f2a283
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion plugins/tickets/src/class/TemplateBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TemplateTable>({ table: 'Template' })

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4f2a283

Please sign in to comment.