Channel user permissions
Does anyone knows what the problem is that I am currently having within a slash command file? I would like to add a person to a channel when the command is executed. At the moment I manage to add the user within the channel permissions but fail to add the correct permissions to this person.
This is because I am getting the following error in my console.
This is because I am getting the following error in my console.
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: SEND_MESSAGES.RangeError [BitFieldInvalid]: Invalid bitfield flag or number: SEND_MESSAGES.const { SlashCommandBuilder, EmbedBuilder, Permissions } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('add')
.setDescription('Wil je een persoon toevoegen aan de ticket?')
.addUserOption(option =>
option.setName('persoon')
.setDescription('Geef de persoon op die je wilt toevoegen aan de ticket.')
.setRequired(true)),
async execute(interaction) {
const user = interaction.options.getUser('persoon');
const ticket = interaction.channel;
await ticket.permissionOverwrites.create(user, {
SEND_MESSAGES: true,
VIEW_CHANNEL: true,
});
console.log(`Gebruiker ${persoon.tag} toegevoegd aan ${ticket.name}`);
const AddEmbed = new EmbedBuilder()
.setColor('#1C6FFF')
.setTitle('Add')
.setDescription('test')
.addFields(
{ name: `Added user:`, value: `${persoon}`},
{ name: `Added by`, value: `<@${interaction.user.id}>`},
{ name: `Ticket:`, value: `<#${interaction.channel.id}>`}
)
.setTimestamp()
await interaction.reply({
content: `${persoon} added to this ticket.`
})
await interaction.guild.channels.cache.get('1193826954655313940').send({
embeds: [AddEmbed]
})
},
};const { SlashCommandBuilder, EmbedBuilder, Permissions } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('add')
.setDescription('Wil je een persoon toevoegen aan de ticket?')
.addUserOption(option =>
option.setName('persoon')
.setDescription('Geef de persoon op die je wilt toevoegen aan de ticket.')
.setRequired(true)),
async execute(interaction) {
const user = interaction.options.getUser('persoon');
const ticket = interaction.channel;
await ticket.permissionOverwrites.create(user, {
SEND_MESSAGES: true,
VIEW_CHANNEL: true,
});
console.log(`Gebruiker ${persoon.tag} toegevoegd aan ${ticket.name}`);
const AddEmbed = new EmbedBuilder()
.setColor('#1C6FFF')
.setTitle('Add')
.setDescription('test')
.addFields(
{ name: `Added user:`, value: `${persoon}`},
{ name: `Added by`, value: `<@${interaction.user.id}>`},
{ name: `Ticket:`, value: `<#${interaction.channel.id}>`}
)
.setTimestamp()
await interaction.reply({
content: `${persoon} added to this ticket.`
})
await interaction.guild.channels.cache.get('1193826954655313940').send({
embeds: [AddEmbed]
})
},
};