Garmaine Staff asked 2 years ago

I have a ticket command which creates a ticket channel that the person that ran the command and staff can see. But recently, it stopped working out of the blue. It does not set permissions. The channel is created though. Here is the code that is giving an error.

Note: ssi, hos, ssi and similar things are variables that return a role id

      message.guild.channels
    .create(message.author.username + "-" + String(ticketid), "text")
    .then(channel => {
      let category = client.channels
        .fetch("693131250667356272")
        .then(category => {
          channel.setParent(category);
        });
      channel.overwritePermissions([
        {
          id: message.member.id,
          allow: [
            "VIEW_CHANNEL",
            "SEND_MESSAGES",
            "READ_MESSAGE_HISTORY",
            "ATTACH_FILES"
          ]
        },
        {
          id: sm,
          allow: [
            "VIEW_CHANNEL",
            "SEND_MESSAGES",
            "READ_MESSAGE_HISTORY",
            "ATTACH_FILES"
          ]
        },
        {
          id: channel.guild.roles.everyone,
          deny: [
            "VIEW_CHANNEL",
            "SEND_MESSAGES",
            "READ_MESSAGE_HISTORY",
            "ATTACH_FILES"
          ]
        },
        {
          id: ssi,
          allow: [
            "VIEW_CHANNEL",
            "SEND_MESSAGES",
            "READ_MESSAGE_HISTORY",
            "ATTACH_FILES"
          ]
        },
        {
          id: hos,
          allow: [
            "VIEW_CHANNEL",
            "SEND_MESSAGES",
            "READ_MESSAGE_HISTORY",
            "ATTACH_FILES"
          ]
        },
        {
          id: m,
          allow: [
            "VIEW_CHANNEL",
            "SEND_MESSAGES",
            "READ_MESSAGE_HISTORY",
            "ATTACH_FILES"
          ]
        },
        {
          id: si,
          allow: [
            "VIEW_CHANNEL",
            "SEND_MESSAGES",
            "READ_MESSAGE_HISTORY",
            "ATTACH_FILES"
          ]
        },
        {
          id: tm,
          allow: [
            "VIEW_CHANNEL",
            "SEND_MESSAGES",
            "READ_MESSAGE_HISTORY",
            "ATTACH_FILES"
          ]
        },
        {
          id: tsi,
          allow: [
            "VIEW_CHANNEL",
            "SEND_MESSAGES",
            "READ_MESSAGE_HISTORY",
            "ATTACH_FILES"
          ]
        }
      ]);
      channel.send(
        "<@" +
          message.author.id +
          "> Here is your ticket channel. Please explain your problem in detail and a staff member will reply in this channel soon. When you want to close the ticket, do `,ticket close`"
      );
    });

The error is where it sets the permissions. Here is what is printed

(node:2507) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied parameter is not an User nor a Role.
   at Function.resolve (/rbd/pnpm-volume/1610b021-5dc3-42d8-a00c-f4489c1bc502/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/structures/PermissionOverwrites.js:177:28)
    at /rbd/pnpm-volume/1610b021-5dc3-42d8-a00c-f4489c1bc502/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/structures/GuildChannel.js:338:92
    at Array.map (<anonymous>)
    at TextChannel.edit (/rbd/pnpm-volume/1610b021-5dc3-42d8-a00c-f4489c1bc502/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/structures/GuildChannel.js:338:62)
    at TextChannel.overwritePermissions (/rbd/pnpm-volume/1610b021-5dc3-42d8-a00c-f4489c1bc502/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/structures/GuildChannel.js:211:17)
at /app/server.js:264:19
    at processTicksAndRejections (internal/process/task_queues.js:88:5)
(node:2507) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:2507) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.