I am currently working on a discord bot using Discord.js V14 and implementing a command called "claimticket". However, I am facing an issue where I need to restrict this command to only members who possess one of the two specific roles that I have mentioned in the command.
If possible, I am seeking assistance to limit the usage of the claimticket command to only those members who have either of the two specified roles! Below is the full code snippet for the command:
const Discord = require("discord.js");
const config = require("../../config.json")
const StaffRolesPermitted = [`${config["ID-role"].staff}`, `${config["ID-role"]["trial-helper"]}`];
module.exports = {
name: "claimticket",
description: "claim a ticket",
run: async (client, interaction) => {
const member = interaction.user;
const hasStaffRole = member.roles.cache.some(role => StaffRolesPermitted.includes(role.id));
if (!hasStaffRole) {
return interaction.reply({ content: "You do not have permission to use this command!", ephemeral: true });
} else {
let embed = new Discord.EmbedBuilder()
.setColor("Green")
.setFooter({ text: `${config.servidor.footer}`, iconURL: `${config.servidor.logo}`})
.setDescription(`**This Ticket will be serviced by ${interaction.user}!**`)
await interaction.reply({ embeds: [embed] });
}
}
}