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

401
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

let everyoneRole = message.guild.id;

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

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