DiscordJS角色权限

时间:2020-04-25 10:52:50

标签: arrays node.js discord.js difference

当我收到某个角色的权限更改(如果禁用或启用了任何其他权限)时,它可以正确显示,但是当我启用或禁用管理员时,它会发送所有权限,并且我无法确定除admin以外的其他权限是否被禁用或启用。

let oldPerm = new Discord.Permissions(change.old).toArray();
      let newPerm = new Discord.Permissions(change.new).toArray();
      let arr = [];
      let removedPerm = oldPerm.filter(x => newPerm.indexOf(x) === -1);
      if(removedPerm.length > 0) {
        removedPerm.forEach(perm => {
          arr.push(`- ${perm}`);
        });
      }
      let addedPerm = newPerm.filter(x => oldPerm.indexOf(x) === -1);
      if(addedPerm.length > 0) {
        addedPerm.forEach(perm => {
          arr.push(`+ ${perm}`);
        });
      }

0 个答案:

没有答案