I’m developing a discord bot in Discord.js V14 and I’m working on a command called "claimticket". The problem I’m having is that I’m not being able to restrict the command to anyone who has one of the two roles that I indicate in the command.
If possible, I would like help to restrict the claimticket command to only be used by members who have at least 1 of two roles! Below I send the command code in full.
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 StaffRolesPermitted = member.roles.cache.some(role => StaffRolesPermitted.includes(role.id));
if (!StaffRolesPermitted) {
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: });
}
}
}
2
Answers
Not sure, but i would try this maybe :
Check Docs https://discord.js.org/docs/packages/collection/main/Collection:Class#hasAny