Discord.js: Changing channel permissions immediatly after creating a new channel doesn't work

Created on 20 Oct 2020  Â·  2Comments  Â·  Source: discordjs/discord.js

Hi there,
this is my first time using Github issues so please forgive me if I do something wrong 😄

Anyway,
A while ago (like 4 months ago) I created a ticket system for my discord bot. Someone would type !help and it would create a new channel where role x, role xx and the ticket creator could talk. It would send a nice embed with information about the system and would ping the creator. However, like 2 months ago, it broke for the first time.

My issue basically;
Everything works fine, except the overwriting permissions part. It syncs the permissions with the category it's under and it doesn't matter if I put it under a category or not. If I don't put it under a category nobody but the people with Admin perms can see it.

Here's my code.

message.guild.channels.create(`ticket-${message.author.id}`, 'text', {
          permissionOverwrites: [
                {
                    id: message.guild.id, 
                    deny: ['SEND_MESSAGES', 'READ_MESSAGES', 'VIEW_CHANNEL', 'READ_MESSAGE_HISTORY'],
                  },
                  {
                    id: `748615632253354128`, 
                    deny: ['MANAGE_MESSAGES'], 
                    allow: ['SEND_MESSAGES', 'VIEW_CHANNEL', 'READ_MESSAGES', 'READ_MESSAGE_HISTORY'],
                  },
                  {
                    id: `746481468611493908`, 
                    deny: ['MANAGE_MESSAGES'], 
                    allow: ['SEND_MESSAGES', 'VIEW_CHANNEL', 'READ_MESSAGES', 'READ_MESSAGE_HISTORY'],
                  },
                  {
                    id: message.author.id, 
                    deny: ['MANAGE_MESSAGES'], 
                    allow: ['SEND_MESSAGES', 'ATTACH_FILES', 'VIEW_CHANNEL', 'READ_MESSAGES', 'READ_MESSAGE_HISTORY'],
                  },
               ],
            }).then(c => {
      if (message.guild.id === `742578659407429814`){
          okEmbed.setAuthor(`Ticket | Emitter`, `https://cdn.discordapp.com/attachments/746495593840508939/758125684593262683/Track-x-transparent.png`)
          c.setParent('748704520208646165');
      }else if (message.guild.id === `748201626774536272`){
          c.setParent(`758123663727132673`);
      }
      c.send(okEmbed);
      if (message.guild.id === `742578659407429814`){
         c.send(`**Wake up <@&748615632253354128>  &  <@&742591810412740649>,  ${message.author} is in need of support!**`)
    }else if (message.guild.id === `748201626774536272`){
        c.send(`**Wake up <@&755213451839799437>  &  <@&748235877813059759>,  ${message.author} is in need of support!**`)
      }

I don't get any errors.

Thanks in advance!

question (please use Discord instead)

All 2 comments

Ok so what's wrong with it like what I mean is can you send me a video of
the problem like I know what you mean but I just dont want to make any
mistakes so yeah just send me a video of the problem and we will be all set
to go thanks

      -SlummpyQT

On Mon, Oct 19, 2020, 7:37 PM Skyknight47 notifications@github.com wrote:

Hi there,
this is my first time using Github issues so please forgive me if I do
something wrong 😄

Anyway,
A while ago (like 4 months ago) I created a ticket system for my discord
bot. Someone would type !help and it would create a new channel where role
x, role xx and the ticket creator could talk. It would send a nice embed
with information about the system and would ping the creator. However, like
2 months ago, it broke for the first time.

My issue basically;
Everything works fine, except the overwriting permissions part. It syncs
the permissions with the category it's under and it doesn't matter if I put
it under a category or not. If I don't put it under a category nobody but
the people with Admin perms can see it.

Here's my code.

message.guild.channels.create(ticket-${message.author.id}, 'text', {

      permissionOverwrites: [

            {

                id: message.guild.id,

                deny: ['SEND_MESSAGES', 'READ_MESSAGES', 'VIEW_CHANNEL', 'READ_MESSAGE_HISTORY'],

              },

              {

                id: `748615632253354128`,

                deny: ['MANAGE_MESSAGES'],

                allow: ['SEND_MESSAGES', 'VIEW_CHANNEL', 'READ_MESSAGES', 'READ_MESSAGE_HISTORY'],

              },

              {

                id: `746481468611493908`,

                deny: ['MANAGE_MESSAGES'],

                allow: ['SEND_MESSAGES', 'VIEW_CHANNEL', 'READ_MESSAGES', 'READ_MESSAGE_HISTORY'],

              },

              {

                id: message.author.id,

                deny: ['MANAGE_MESSAGES'],

                allow: ['SEND_MESSAGES', 'ATTACH_FILES', 'VIEW_CHANNEL', 'READ_MESSAGES', 'READ_MESSAGE_HISTORY'],

              },

           ],

        }).then(c => {

  if (message.guild.id === `742578659407429814`){

      okEmbed.setAuthor(`Ticket | Emitter`, `https://cdn.discordapp.com/attachments/746495593840508939/758125684593262683/Track-x-transparent.png` <https://cdn.discordapp.com/attachments/746495593840508939/758125684593262683/Track-x-transparent.png>)

      c.setParent('748704520208646165');

  }else if (message.guild.id === `748201626774536272`){

      c.setParent(`758123663727132673`);

  }

  c.send(okEmbed);

  if (message.guild.id === `742578659407429814`){

     c.send(`**Wake up <@&748615632253354128>  &  <@&742591810412740649>,  ${message.author} is in need of support!**`)

}else if (message.guild.id === `748201626774536272`){

    c.send(`**Wake up <@&755213451839799437>  &  <@&748235877813059759>,  ${message.author} is in need of support!**`)

  }

I don't get any errors.

Thanks in advance!

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/discordjs/discord.js/issues/4923, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AROBJY7NQVKYBSVGJPEATALSLTZWZANCNFSM4SXJVR5A
.

Please use the methods as they are documented. GuildChannelManager#create takes two parameters, name and options, not three. This might have happened during the v11 -> v12 update, we have a guide page listing most of the relevant changes: https://discordjs.guide/additional-info/changes-in-v12.html


If you need help with discord.js installation or usage, please go to the discord.js Discord server instead:
https://discord.gg/bRCvFy9
This issue tracker is only for bug reports and enhancement suggestions. You won't receive any basic help here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smchase picture smchase  Â·  3Comments

Alipoodle picture Alipoodle  Â·  3Comments

Brawaru picture Brawaru  Â·  3Comments

LLamaFTL picture LLamaFTL  Â·  3Comments

Blumlaut picture Blumlaut  Â·  3Comments