【问题标题】:RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: 3214336RangeError [BITFIELD_INVALID]:无效的位域标志或编号:3214336
【发布时间】:2022-01-12 23:16:39
【问题描述】:

我试图做一个 Discord 仪表板,但我得到一个奇怪的错误:无效的位域标志或数字 3214336。当我试图获取用户拥有 MANAGE_GUILDS 的公会时会发生这种情况,我的代码是:

<%- include("../Includes/header", { bot, path, user, Discord, title: 'Dashboard' }) %>
<div class="content">

<h2>SELECT A SERVER</h2>


<div class="servers">
<% user.guilds.forEach(guild => {
 const permsOnGuild = new Discord.Permissions(guild);
 if(!permsOnGuild.has("MANAGE_GUILD")) {
 return
 }

   if (!bot.guilds.cache.get(guild.id)) { 
    return
   } 
 if (guild.icon) {
 iconurl = "https://cdn.discordapp.com/icons/" + guild.id + "/" + guild.icon + ".png??size=512";
} else {
 iconurl = "https://cdn.glitch.com/82fe990a-7942-42e3-9790-39807ccdb9f6%2Ficon-404-dark.png?v=1602427904949";
}
%>
<div class="server">
  <div class="icon-and-name">
<img class="server-icon" src="<%= iconurl %>" alt="<% guild.name %>"/>
  <p class="guild-name"><%= guild.name %></p>
  </div>
  <% if (bot.guilds.cache.get(guild.id)) { %>
    <a class="edit button" href="/redeem/<%= guild.id %>">Redeem</a>
  <% } %>
</div>
  <% }); %>
</div>

<script>
    function PopupCenter(e, n, t, i) {
        var o = void 0 != window.screenLeft ? window.screenLeft : screen.left,
            d = void 0 != window.screenTop ? window.screenTop : screen.top,
            c = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width,
            w = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height,
            r = c / 2 - t / 2 + o, h = w / 2 - i / 2 + d,
            s = window.open(e, n, "scrollbars=yes, width=" + t + ", height=" + i + ", top=" + h + ", left=" + r);
        window.focus && s.focus()
    }
</script>

我知道为什么会发生这种情况,如果我登录“公会”,我可以访问 id、名称、图标、所有者、权限、功能和 permissions_new

【问题讨论】:

    标签: javascript node.js express discord.js ejs


    【解决方案1】:

    尝试做

    let permsOnGuild = new Discord.Permissions(BigInt(guild.permissions));
    if (! permsOnGuild.has(Discord.Permissions.FLAGS.MANAGE_GUILD)) return;
    

    【讨论】:

      猜你喜欢
      • 2020-12-10
      • 2021-08-05
      • 2022-06-13
      • 2021-12-25
      • 2021-12-12
      • 2021-01-03
      • 1970-01-01
      • 1970-01-01
      • 2020-10-31
      相关资源
      最近更新 更多