abort submit if response name is taken

This commit is contained in:
Baipyrus 2024-04-05 10:57:32 +02:00
parent b812d0e74d
commit 0688dad57b

View File

@ -398,6 +398,22 @@ export async function modalSubmit(interaction) {
}
});
// Abort if response exists
if (
(await Responses.findOne({
where: {
keyword: found.id,
name
}
})) !== null
) {
await interaction.reply({
content: `Response with name '${name}' already exists!`,
ephemeral: true
});
return;
}
// Create new response data with keyword attached
await Responses.create({ keyword: found.id, name, response });