I'm using Node.JS to create a discord bot in which a new role and channel are created with the same command. For the sake of simplicity, both the name of the role and the name of the channel are the first argument of the command:
let chanName = args[0];
let roleName = args[0];
Following the name of the role/channel is a list of mentions - these are the users that receive the new role. The role is created just fine, the channel is created just fine, and the members are added to the role just fine, but I'm having trouble setting up permissions where only users with the new role OR the 'administrator' role are able to see the channel.
The channel is created like so:
message.guild.channels.create(chanName, {
type: "text"
})
.then((channel) => {
//Each new channel is created under the same category
const categoryID = '18-digit-category-id';
channel.setParent(categoryID);
})
.catch(console.error);
It appears as though the channel is not added to the guild cache
let chan = message.guild.channels.cache.find(channel => channel.name === chanName);
because this code returns 'undefined' to the console.
Is there any way I can allow the mentioned users to interact (view, send messages, add reactions...) with this new channel?