3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

fix permissions not showing properly in roleinfo

This commit is contained in:
almeidx 2021-11-26 11:49:08 +00:00
parent 3b98c3bdc1
commit 95365d8573
No known key found for this signature in database
GPG key ID: F403F80B79353CB4
2 changed files with 51 additions and 9 deletions

View file

@ -1,8 +1,9 @@
import { MessageEmbedOptions, Role } from "discord.js";
import { MessageEmbedOptions, Permissions, Role } from "discord.js";
import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub";
import moment from "moment-timezone";
import { EmbedWith, preEmbedPadding, trimLines } from "../../../utils";
import { permissionNames } from "../../../utils/permissionNames.js";
import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin";
import { UtilityPluginType } from "../types";
@ -35,14 +36,9 @@ export async function getRoleInfoEmbed(
round: true,
});
const rolePerms = Object.keys(role.permissions.toJSON()).map((p) =>
p
// Voice channel related permission names start with 'voice'
.replace(/^voice/i, "")
.replace(/([a-z])([A-Z])/g, "$1 $2")
.toLowerCase()
.replace(/(^\w{1})|(\s{1}\w{1})/g, (l) => l.toUpperCase()),
);
const rolePerms = role.permissions.has(Permissions.FLAGS.ADMINISTRATOR)
? [permissionNames.ADMINISTRATOR]
: role.permissions.toArray().map((p) => permissionNames[p]);
// -1 because of the @everyone role
const totalGuildRoles = pluginData.guild.roles.cache.size - 1;