Assistance getting role by ID

Im trying to get a role via ID, however, whenever i pass that roleID to permissions override in channel.create, it throws a error saying its neither a role nor a User, can i not give channel permissions this way?


Code snippet:

  guild.channels
  .create({
    name: ticketID,
    type: ChannelType.GuildText,
    topic: `Type: ${Type} | ID: ${ticketID} | Urgent: ${Urgent} | Created: ${currentDate} | Status: Open | Started by: ${interaction.user.username}`,
    parent: category,
    permissionOverwrites: [
    {
      id: interaction.user.id, // <- works fine
      allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.ReadMessageHistory],
    },
    {
      id: interaction.guild.roles.cache.get("1122921112532156488"),
      allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.ReadMessageHistory],
    }


Error
Error creating channel: TypeError [InvalidType]: Supplied parameter is not a User nor a Role.
    at PermissionOverwrites.resolve (...\Discord\node_modules\discord.js\src\structures\PermissionOverwrites.js:184:28)
    at ...\Discord\node_modules\discord.js\src\managers\GuildChannelManager.js:168:81
    at Array.map (<anonymous>)
    at GuildChannelManager.create (...\Discord\node_modules\discord.js\src\managers\GuildChannelManager.js:168:51)
    at Object.execute (.../Discord/Interactions/Commands/hello.js:114:4)
    at Object.execute (.../Discord/Events/Client/interactionCreate.js:39:30)
    at Client.<anonymous> (.../Discord/Utilities/eventHandler.js:33:23)
    at Client.emit (node:events:512:28)
    at InteractionCreateAction.handle (...\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
    at module.exports [as INTERACTION_CREATE] (...\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36) {        
  code: 'InvalidType'
}

Full Code:
hastebin.com/share/tifugigeno.javascript
Was this page helpful?