• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • About
  • Life
  • Tech
  • Travel
  • Work
  • Questions
  • Contact

Welcome

.

Trouble setting channel permissions in discord.js

April 10, 2020 by

Questions › Trouble setting channel permissions in discord.js
0
Vote Up
Vote Down
Garmaine asked 3 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.
Are you looking for the answer?
Original Question and Possible Answers can be found on `http://stackoverflow.com`

Question Tags: discord, discord.js, javascript, node.js

Please login or Register to submit your answer




Primary Sidebar

Tags

Advancements best Business strategies commercial convenience economic Finances Cognitive decline Financial growth firm Future Hidden Gems Home hydration Impact Innovations lighting line of work Mental health Must-See New York City office patronage Productivity profession Profitability tips Profit optimization pursuit recreation Revenue enhancement romance sippy cups social station Technological breakthroughs technology toddlers trading transaction Treasures Uncover undertaking Well-being Wonders Work Young onset dementia

Newsletter

Complete the form below, and we'll send you all the latest news.

Footer

Footer Funnies

Who knew that reading the footer could be such a hilarious adventure? As we navigate websites, books, and documents, we often stumble upon the unassuming space at the bottom, only to discover a treasure trove of amusement. In this side-splitting compilation, we present 100 jokes that celebrate the unsung hero of content – the footer. Get ready to chuckle, giggle, and maybe even snort as we dive into the world of footnotes, disclaimers, and hidden comedic gems. Brace yourself for a wild ride through the footer!

Recent

  • Unveiling the Enigma: Almost-Magical Lamp Lights Highway Turns
  • The Impact of Young Onset Dementia on Employment and Finances: Optimizing Post-Diagnostic Approaches
  • 11 Wonders of 2023 Technological Breakthrough – Unveiling the Future
  • Work from Home and Stay Mentally Sane – Achieve Productivity and Well-being
  • Hidden Gems of New York City – Uncover the Must-See Treasures!

Search

Tags

Advancements best Business strategies commercial convenience economic Finances Cognitive decline Financial growth firm Future Hidden Gems Home hydration Impact Innovations lighting line of work Mental health Must-See New York City office patronage Productivity profession Profitability tips Profit optimization pursuit recreation Revenue enhancement romance sippy cups social station Technological breakthroughs technology toddlers trading transaction Treasures Uncover undertaking Well-being Wonders Work Young onset dementia

Copyright © 2023