【问题标题】:Invalid bitfield flag or number: 37035584无效的位域标志或编号:37035584
【发布时间】:2021-12-12 08:20:36
【问题描述】:

我正在处理机器人仪表板,目前不想显示仪表板页面。现在我根本不知道我的问题。

dashboard.ejs

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

错误

RangeError [BITFIELD_INVALID]: /home/runner/switch-beta-bot/dashboard/templates/dashboard.ejs:22
    20| 
    21| <div class="servers">
 >> 22| <% user.guilds.forEach(guild => {
    23|  const permsOnGuild = new perms(guild.permissions);
    24|  if(!permsOnGuild.has("MANAGE_GUILD")) {
    25|  return

Invalid bitfield flag or number: 37035584.
    at Function.resolve (/home/runner/switch-beta-bot/node_modules/discord.js/src/util/BitField.js:152:11)
    at new BitField (/home/runner/switch-beta-bot/node_modules/discord.js/src/util/BitField.js:17:38)
    at new Permissions (/home/runner/switch-beta-bot/node_modules/discord.js/src/util/Permissions.js:11:1)
    at eval ("/home/runner/switch-beta-bot/dashboard/templates/dashboard.ejs":23:23)
    at Array.forEach (<anonymous>)
    at eval ("/home/runner/switch-beta-bot/dashboard/templates/dashboard.ejs":22:20)
    at dashboard (/home/runner/switch-beta-bot/node_modules/ejs/lib/ejs.js:692:17)
    at tryHandleCache (/home/runner/switch-beta-bot/node_modules/ejs/lib/ejs.js:272:36)
    at View.exports.renderFile [as engine] (/home/runner/switch-beta-bot/node_modules/ejs/lib/ejs.js:489:10)
    at View.render (/home/runner/switch-beta-bot/node_modules/express/lib/view.js:135:8)
    at tryRender (/home/runner/switch-beta-bot/node_modules/express/lib/application.js:640:10)
    at Function.render (/home/runner/switch-beta-bot/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/home/runner/switch-beta-bot/node_modules/express/lib/response.js:1012:7)
    at renderTemplate (/home/runner/switch-beta-bot/dashboard/dashboard.js:132:11)
    at /home/runner/switch-beta-bot/dashboard/dashboard.js:633:7
    at Layer.handle [as handle_request] (/home/runner/switch-beta-bot/node_modules/express/lib/router/layer.js:95:5)

【问题讨论】:

  • 你的permissions数组是什么样子的?
  • 目前我的dashboard.js 文件中的内容是lang-js renderTemplate(res, req, "dashboard.ejs", { perms: Discord.Permissions, userExists: user, }); 我仍然不知道错误的来源。
  • 请在您的帖子中添加任何额外信息。不发表评论。
  • 我的意思是“gulld”角色。 See this other bug about the same error.我不知道它是否适用,因为你没有发布很多代码。
  • 我试图向每个服务器显示用户将拥有网站上的 Manage Guild 权限,目前显示我的机器人在 discord.js V13 上运行的 BitField 错误,所以我不这样做'不知道错误来自哪里。

标签: javascript ejs


【解决方案1】:

大约几个小时后,我实际上找到了代码的修复程序。这并不像看起来那么容易。

新代码

<% user.guilds.forEach(guild => {
 if(guild.permissions !== 2147483647) {
 return;
 }
%>

现在这解决了我的问题。

【讨论】:

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