#DiscordAPIError Unknown application command permissions

1 messages · Page 1 of 1 (latest)

sinful shadow
#
const { Permissions } = require("discord.js");
module.exports.permissions = (bot) => [
  {
    id: bot.config.guildId,
    type: "ROLE",
    perms: ["combine", "coinflip", "inventory", "redeem", "changefaction"],
  },
  {
    id: bot.guilds.cache
      .get(bot.config.guildId)
      .members.cache.filter((r) =>
        r.permissions.has(Permissions.FLAGS.ADMINISTRATOR)
      )
      .map((r) => r.id),
    type: "USER",
    perms: ["ALL"],
  },
  {
    id: "941470706867240960",
    type: "ROLE",
    perms: ["ALL"],
  },
  {
    id: "941470719152373880",
    type: "ROLE",
    perms: ["ALL"],
  },
];
    for (let cm of cmds.values()) {
      for (let perm of await cm.permissions.fetch()) {
        perms = [];
        for (let prm of permissions.permissions(bot)) {
          if (typeof prm.id == "object") {
            for (let x of prm.id) {
              perms.push({
                id: x,
                type: prm.type,
                permission:
                  prm.perms.includes("ALL") || prm.perms.includes(cm.name),
              });
            }
          }
          if (typeof prm.id == "string") {
            if (prm.perms.some((r) => r == cm.name)) {
              perms.push({
                id: prm.id,
                type: prm.type,
                permission: true,
              });
            } else {
              if (prm.perms.some((r) => r == "ALL")) {
                perms.push({
                  id: prm.id,
                  type: prm.type,
                  permission: true,
                });
              } else {
                perms.push({
                  id: prm.id,
                  type: prm.type,
                  permission: false,
                });
              }
            }
          }
        }
      }
      if (bot.config.debug) console.log(cm.name, perms);
      cm.permissions.set({ permissions: perms }).catch((e) => {
        console.log(e);
      });
    }