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.
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]
})
},
};
3 Replies
d.js toolkit
d.js toolkit5mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
d.js docs
d.js docs5mo ago
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined - All SCREAMING_SNAKE_CASE enums have been changed to PascalCase - Intents: Intents.FLAGS.GUILD_MESSAGES -> GatewayIntentBits.GuildMessages - Permissions: Permissions.FLAGS.SEND_MESSAGES -> PermissionFlagsBits.SendMessages
Gerben
Gerben5mo ago
Thx for your feedback. I'm going to give it a try.