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

238
Vistas
permission over write after channel creation, using discord.js

I'm having some issues with giving the message.author and staff permission to see the channel right after it's created, the issue is, when the channel's parent (category) is changed, it syncs the permissions of the parent (category), which disallows the user and staff to see the channel, I'm not sure how to fix this, I wish I explained well, if you have any questions, please ask.

Here is my code:

module.exports = {
  name: 'new',
  category: 'Ticket',
  description: 'Creates a new ticket.',
  aliases: ['newticket'],
  usage: 'New',
  userperms: [],
  botperms: [],
  run: async (client, message, args) => {
    if(message.author.bot) return;
    if(!message.channel.id == process.env.COMMAND_T) return;
if(!client.userTickets) {
  client.userTickets = new Map();

  const channels = message.guild.channels.cache.filter(channel => {
    if(channel) return channel.name.startsWith('t-');
    });

    if(channels) {
      for (i in Array.from(channels)) {
        client.userTickets.set(i, +i + 1);
    }
  }
}
console.log(client.userTickets)
        if(client.userTickets.has(message.author.id)) {
            return message.channel.send('<@' + message.author.id + 'You already have a ticket, please close it then run this command again!').then(m => m.delete({timeout: 10000}));
        }
        message.guild.channels.create(`t-${client.userTickets.size + 1}`, {
            permissionOverwrites: [
                {
                    id: message.author.id,
                    allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
                },
                {
                    id: process.env.ROLE_STAFF,
                    allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
                },
                {
                    id: process.env.ROLE_MEMBER,
                    deny: ['VIEW_CHANNEL']
                }
            ],
            type: 'text',
        }).then(async channel => {
            channel.setParent(process.env.TICKET_C);
            client.userTickets.set(message.author.id, client.userTickets.size + 1);
            message.channel.send(`<@` + message.author.id + `>, Done, go to your ticket! ${channel}`).then(m => m.delete({timeout: 10000}));
            client.users.cache.get(message.author.id).send(`Your ticket has been opened, go take a look: ${channel}`)
            channel.send(`Hi <@` + message.author.id + `>, Hello and welcome to your DwaCraft ticket!`);
            channel.send(`https://tenor.com/view/is-there-something-i-can-help-you-with-dan-levy-david-david-rose-schitts-creek-gif-20776045`);
            
            const logchannel = message.guild.channels.cache.find(channel => channel.id === process.env.TICKET_L);
            
            if(logchannel) {
                logchannel.send(`There was a new ticket created by <@${message.author.id}>! Channel: <#${channel.id}>`);
            }
        });
    }
}

Note: I've researched but I didn't find any answer.

Thanks for taking the time to read this.

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

0

Try this

message.guild.channels.create(`t-${client.userTickets.size + 1}`, {
                type: 'GUILD_TEXT',
                permissionOverwrites: [
                    {
                        id: process.env.ROLE_STAFF,
                        allow: ['VIEW_CHANNEL'],
                    },
                    {
                        id: message.author.id,
                        allow: ['VIEW_CHANNEL'],
                    },
                ],
                parent: process.env.CATEGORY
            });

This code is mine, but it is shortened, if you like the complete one send me DM

P.S I just have it for my ticket system

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