The command I've written will take a set of role names, find their role IDs and then creates a channel that only the role names will be able to see.
const members = memberNames.map((name) => {
let role = interaction.guild.roles.cache.find(
(r) => r.name.toLowerCase() === name.toLowerCase(),
)
if (!role) {
return null
}
console.log(role.id)
return { id: role.id, allow: ['VIEW_CHANNEL'] }
})
try {
const channel = await interaction.guild.channels.create({
name: allianceNameInput,
type: 'text',
parent: alliancesCategory.id,
permissionOverwrites: [
...members,
{
id: interaction.guild.roles.everyone.id,
deny: ['VIEW_CHANNEL'],
},
],
})
await interaction.reply(`Created alliance channel: ${channel}`)
} catch (error) {
console.error('Could not create alliance channel.', error)
await interaction.reply({
content: 'Could not create alliance channel.',
ephemeral: true,
})
}
I keep getting the following error message:
Could not create alliance channel. RangeError [BitFieldInvalid]: Invalid bitfield flag or number: VIEW_CHANNEL.
I've read through the documentation and some other peoples code and I can't find any other way to make it work so I don't know exactly what to do here.