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

400
Visualizações
How can I deny @everyone and allow the author to view the channel?

I've been tinkering around with this for a while, and I have never done permission based channel creation. I am working on a ticket function for my bot and I can't quite seem to get it working. The idea is to create a channel with set permissions named the message.author entire tag with the permissions set to only allow the message.author to see the channel. For some reason I keep running into an error. How can I fix this? I've defined the everyone role and message.author should already be defined. Am I missing something?

if (message.channel.type !== "text") {
  let active = db.fetch(`support_${message.author.id}`)
  let guild = client.guilds.cache.get('took out ID')
  let channel, found = true

  try {
    if (active) client.channels.cache.get(active.channelID).guild
  } catch (e) {
    found = false;
  }

  if(!active || !found) {
    active = {}

    let everyoneRole = msg.guild.roles.cache.find(r => r.name === '@everyone');

    channel = await guild.channels.create(`${message.author.username}-${message.author.discriminator}`, {
      parent: 'took out ID',
      topic: `Support for ${message.author.tag} | ID: ${message.author.id}`,
      permissionOverwrites: [
        {
          id: everyoneRole.id,
          deny: ['VIEW_CHANNEL'],
          
          id: message.author.id,
          allow: ['VIEW_CHANNEL'],
        },
      ],
  })
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can either use roles.everyone that returns the @everyone role of the guild or simply use the guild's ID. Also, your overwrites are incorrect. It should contain two objects; one that denies views for everyone, and one that allows it for the member who sent the message.

Any of these will work:

let permissionOverwrites = [
  {
    id: message.guild.roles.everyone.id,
    deny: ['VIEW_CHANNEL'],
  },
  {
    id: message.author.id,
    allow: ['VIEW_CHANNEL'],
  },
];

let channel = await guild.channels.create(
  `${message.author.username}-${message.author.discriminator}`,
  {
    parent: 'took out ID',
    topic: `Support for ${message.author.tag} | ID: ${message.author.id}`,
    permissionOverwrites,
  },
);

Or:

let permissionOverwrites = [
  {
    id: message.guild.id,
    deny: ['VIEW_CHANNEL'],
  },
  {
    id: message.author.id,
    allow: ['VIEW_CHANNEL'],
  },
];

let channel = await guild.channels.create(
  `${message.author.username}-${message.author.discriminator}`,
  {
    parent: 'took out ID',
    topic: `Support for ${message.author.tag} | ID: ${message.author.id}`,
    permissionOverwrites,
  },
);
about 4 years ago · Juan Pablo Isaza Relatório

0

let everyoneRole = message.guild.id;

The role for @everyone is the same as the guild id.

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