From 283eaa15f40e36aba8a28fa01421bcb11e3437d7 Mon Sep 17 00:00:00 2001 From: Ninjdai Date: Sat, 13 May 2023 10:18:38 +0200 Subject: [PATCH] Add role requirement to open a ticket --- interactions/buttons/src/ticket/ticketopener.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/interactions/buttons/src/ticket/ticketopener.js b/interactions/buttons/src/ticket/ticketopener.js index 57ba7a4..162a8a2 100644 --- a/interactions/buttons/src/ticket/ticketopener.js +++ b/interactions/buttons/src/ticket/ticketopener.js @@ -1,8 +1,16 @@ -const { ActionRowBuilder, StringSelectMenuBuilder } = require('discord.js') +const { ActionRowBuilder, StringSelectMenuBuilder, EmbedBuilder } = require('discord.js') module.exports = { async execute(interaction) { await interaction.deferReply({ ephemeral: true }); + if(interaction.customId.endsWith("free")){ + if( + !interaction.member.roles.cache.has('1104145272499621928') && + !interaction.member.roles.cache.has('1104146176627970249') && + !interaction.member.roles.cache.has('1104146641721761843') && + !interaction.member.roles.cache.has('1104147264500400142') + ) return interaction.editReply({ embeds: [hasNotRoleEMBED] }) + } const ticketgraphismtyperow2 = new ActionRowBuilder() .addComponents( new StringSelectMenuBuilder() @@ -58,4 +66,9 @@ module.exports = { ); await interaction.editReply({ components: [ticketgraphismtyperow2] }) } -} \ No newline at end of file +} + +const hasNotRoleEMBED = new EmbedBuilder() + .setTitle("Désolé !") + .setColor("#db2a06") + .setDescription('Pour pouvoir ouvrir un ticket bénévole, vous devez avoir le rôle <@&1104145272499621928> !\nCela nous permet de ne pas être noyés sous les commandes tout en laissant l\'accès aux commandes bénévole possible.!') \ No newline at end of file