Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

672
Vistas
How to fix TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role

I'm running into a problem when I'm trying to create a role and a text channel. The role created will set permissions for the text channel.

if (id === '4') {
  message.guild.roles.create({
    name: `Owner`,
    color: `${color.white}`,
    permissions: ['ADD_REACTIONS'],
    hoist: true,
  });

  let owner = message.guild.roles.cache.find((role) => role.name === 'Owner');

  name = `${names.name}`,
    message.guild.channels
      .create(name, {
        type: 'GUILD_TEXT',
        permissionOverwrites: [
          {
            id: owner,
            allow: ['ADD_REACTIONS'],
            deny: ['VIEW_CHANNEL'],
          },
        ],
      })
      .catch((err) => console.log(err));
}

Although it creates the role, when it comes to the text channel, it cannot find the role made and throws an error:

TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role.

I'm unsure how to fix this.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

It looks like you haven't awaited the role create a function. Try using this code:

 if(id === '4'){


        await message.guild.roles.create({
            name: `Owner`,
            color: `${color.white}`,
            permissions: ["ADD_REACTIONS"],
            hoist: true
        });


        let owner = message.guild.roles.cache.find(role => role.name === "Owner");

        name = `${names.name}`,
        await message.guild.channels.create(name, {
            type: "GUILD_TEXT",  
            permissionOverwrites: [{
                id: owner,
                allow: ['ADD_REACTIONS'],
                deny: ['VIEW_CHANNEL']
            }]
        }).catch(err => console.log(err));

    }
about 4 years ago · Juan Pablo Isaza Denunciar

0

roles.create() is an asynchronous method, which means it returns a promise and allows the rest of your code to run without blocking anything. It also means that when you try to find the newly created role on the next line, it won't be there as it's not even created, so it will be undefined. As undefined is not a valid Role or User, you receive a TypeError.

However, roles.create() resolves to the newly created role, so you can wait for it to be created (using await for example) and grab its value. This way you don't even need to find it later. Check out the code below:

let owner = await message.guild.roles.create({
  name: `Owner`,
  color: color.white,
  permissions: ['ADD_REACTIONS'],
  hoist: true,
});

message.guild.channels
  .create(names.name, {
    type: 'GUILD_TEXT',
    permissionOverwrites: [
      {
        // now owner is a valid role
        id: owner,
        allow: ['ADD_REACTIONS'],
        deny: ['VIEW_CHANNEL'],
      },
    ],
  })
  .catch((err) => console.log(err));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda