let myRole = message.guild.roles.cache.find(role => role.name === "Admin");
message.guild.channels.create(
channelName2,
{
type: "GUILD_TEXT",
permissionOverwrites: [
{
id: myRole.id,
allow: ["SEND_MESSAGES", "VIEW_CHANNEL", "READ_MESSAGE_HISTORY"],
},
{
id: myRole.id,
deny: ["VIEW_CHANNEL"]
}
]
}
Bot creates the text channel but has no permissions edited and it ignored almost whatever I write in "id: XXXXXX"
The problem is the way you are editing the permissions,
First you edit it to allow
{
id: myRole.id,
allow: ["SEND_MESSAGES", "VIEW_CHANNEL", "READ_MESSAGE_HISTORY"],
}
Then you edit to deny permissions
{
id: myRole.id,
deny: ["VIEW_CHANNEL"]
}
However by doing it twice you undo the permissions of the first time, the correct way to do it would be by making it into one object:
message.guild.channels.create(
channelName2,
{
type: "GUILD_TEXT",
permissionOverwrites: [
{
id: myRole.id,
allow: ["SEND_MESSAGES", "VIEW_CHANNEL", "READ_MESSAGE_HISTORY"],
deny: ["VIEW_CHANNEL"]
}
]
}