Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
Discord.js | Multiple channel permission - Everyone & created role

I would like to create a channel with specific permissions for @everyone and a created role. So I defined the role as " rolee " and the @everyone at " everyoneRole ", I would like @everyone not to have permission to see the room, and the rolee created before to have permission to see, talk, log in and talk in the room (category type room, but permission is the same).

My code will surely be more concrete: by the way, discord.js is a bit tricky because it only accepts the code if everything is perfectly aligned, which in itself is not a problem, but is when the script doesn't work because of a single misplaced space.

let everyoneRole = message.guild.roles.cache.find(role => role.name === '@everyone');
let rolee = message.guild.roles.cache.find(role => role.name === rolename);

let crole = (
    message.guild.roles.create({
        data: {
            name: rolename,
            color: '3498DB',
        },
    });
);
let cat = (
    message.guild.channels.create(category, {
        type: "category",
        position: 999,
        permissionOverwrites: [
           {
               id: everyoneRole.id,
               deny: [
                   'VIEW_CHANNEL',
                   'SEND_MESSAGES',
               ],
           },
       ]
   });
);

And here is the error message.

My problem is that it refuses to add multiple permission to a single role (allow : ['VIEW_CHANNEL', 'SEND_MESSAGES']).

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Note: This answer is for Discord.js v13.3.0


The TypeError is occurring because when you're getting the role from the list of roles, @everyone is technically not a role. While it is a role, you can't get it by requesting it from the role cache.

// When you try to get it from this, Discord.js returns null
let everyoneRole = message.guild.roles.cache.find(role => role.name === '@everyone');

This means that you're handing Discord an empty ID which then causes the issue. The proper way to get the role for everyone, as pointed out by Niet the Dark Absol, is to use <Guild>.roles.cache.everyone (Replace <Guild> with whatever your Guild variable is). Here's what that would look like.

let everyoneRole = message.guild.roles.cache.everyone
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda