Skip to content

Commit

Permalink
✅ Check if there is already a select with the same name
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu11-A committed Jun 16, 2024
1 parent 3859817 commit 91222bb
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,30 @@ new Component({
const buttonBuilder = new TemplateButtonBuilder()

if (templateData === null) {
await interaction.reply({ embeds: [notFound] })
await interaction.reply({ embeds: [notFound], ephemeral: true })
return
}

templateData.selects = [ ...(templateData.selects ?? []), { emoji, title, description }]
const exist = (templateData.selects ?? []).find((select) => select.title.toLowerCase() === title.toLowerCase())

if (exist !== undefined) {
await interaction.reply({
ephemeral: true,
embeds: [new EmbedBuilder({
title: 'Já existe um select com este nome, tente outro que não exista!'
}).setColor('Red')]
})
return
}

templateData.selects = [
...(templateData.selects ?? []),
{
emoji,
title,
description
}
]

await templateDb.save(templateData)
.then(async () => {
Expand Down

0 comments on commit 91222bb

Please sign in to comment.