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

243
Visualizações
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 Respostas
Responde à pergunta

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 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