I am working on a bot dashboard and currently the dashboard page doesn't want to display. Now I don't know my issue at all.
dashboard.ejs
<div class="servers">
<% user.guilds.forEach(guild => {
const permsOnGuild = new perms(guild.permissions);
if(!permsOnGuild.has("MANAGE_GUILD")) {
return
}
%>
Error
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)
After about a few hours I actually found the fix to the code. It wasn't as easy as it looks.
NEW CODE
<% user.guilds.forEach(guild => {
if(guild.permissions !== 2147483647) {
return;
}
%>
Now that solves my issue.