'overwritePermissions not functioning| Discord.js MASTER

I am in the process of converting my bot to work with the master branch of discord.js I got to my ticket command and they changed a lot, I managed to do everything apart from the overwritePermissions section. I am unsure of why the code is not working. If I remove the bottom 2 overwritePermissions sections, it works fine, but with all 3 present, none execute.

        let role = message.channel.guild.defaultRole;
        let role2 = message.guild.roles.find(x => x.name === "Support Team");
        message.guild.channels.create(`ticket-test`, {type: 'text'}).then(c => {
            c.overwritePermissions({
                permissionOverwrites: [{
                    id: role.id,
                    deny: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
                }]
            });
            c.overwritePermissions({
                permissionOverwrites: [{
                    id: role2.id,
                    deny: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
                }]
            });
            c.overwritePermissions({
                permissionOverwrites: [{
                    id: message.author.id,
                    allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
                }]
            });
        });

I have done console.log(role.id) and console.log(role2.id and they both show the correct id, it's just not executing the code.



Solution 1:[1]

let role2 = message.guild.roles.find(x => x.name === "?Mods");

but if you want for this:

async function jointocreatechannel(user) {
  //log it 
  console.log(" :: " + user.member.user.username + "#" + user.member.user.discriminator + " :: Created a Support")
  //user.member.user.send("This can be used to message the member that a new room was created")
  await user.guild.channels.create(`${user.member.user.username}'s Support`, {
    type: 'voice',
    parent: "973217461577080903", //or set it as a category id
  }).then(async vc => {
    //move user to the new channel
    user.setChannel(vc);
    //set the new channel to the map
    jointocreatemap.set(`tempvoicechannel_${vc.guild.id}_${vc.id}`, vc.id);
    //change the permissions of the channel
    let role2 = message.guild.roles.find(x => x.name === "?Mods");
    await vc.overwritePermissions([
      {
        id: user.id,
        allow: ['MANAGE_CHANNELS'],
      },
      {
        id: user.guild.id,  
        deny: ['VIEW_CHANNEL'],
      },
      {
        id: role2.id,
        deny: ['VIEW_CHANNEL'],
      },
    ]);
  })
}
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tyler2P