diff --git a/backend/src/plugins/Utility/commands/RoleInfoCmd.ts b/backend/src/plugins/Utility/commands/RoleInfoCmd.ts index 13c26802..f374bea3 100644 --- a/backend/src/plugins/Utility/commands/RoleInfoCmd.ts +++ b/backend/src/plugins/Utility/commands/RoleInfoCmd.ts @@ -10,17 +10,11 @@ export const RoleInfoCmd = utilityCmd({ permission: "can_roleinfo", signature: { - role: ct.role({ required: false }), + role: ct.role({ required: true }), }, async run({ message, args, pluginData }) { - if (!args.role) { - sendErrorMessage(pluginData, message.channel, "Role not found"); - return; - } - const embed = await getRoleInfoEmbed(pluginData, args.role, message.author.id); - message.channel.createMessage({ embed }); }, }); diff --git a/backend/src/plugins/Utility/functions/getRoleInfoEmbed.ts b/backend/src/plugins/Utility/functions/getRoleInfoEmbed.ts index 216b3991..5dcfcb26 100644 --- a/backend/src/plugins/Utility/functions/getRoleInfoEmbed.ts +++ b/backend/src/plugins/Utility/functions/getRoleInfoEmbed.ts @@ -35,16 +35,17 @@ export async function getRoleInfoEmbed( round: true, }); - const rolePerms = Object.keys(role.permissions.json) - .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()), - ) - .join(", "); + const rolePerms = Object.keys(role.permissions.json).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()), + ); + + // -1 because of the @everyone role + const totalGuildRoles = pluginData.guild.roles.size - 1; embed.fields.push({ name: preEmbedPadding + "Role information", @@ -52,14 +53,14 @@ export async function getRoleInfoEmbed( Name: **${role.name}** ID: \`${role.id}\` Created: **${roleAge} ago** (\`${prettyCreatedAt}\`) - Position: **${role.position}** + Position: **${role.position} / ${totalGuildRoles}** Color: **#${role.color .toString(16) .toUpperCase() .padStart(6, "0")}** Mentionable: **${role.mentionable ? "Yes" : "No"}** Hoisted: **${role.hoist ? "Yes" : "No"}** - Permissions: \`${rolePerms}\` + Permissions: \`${rolePerms.length ? rolePerms.join(", ") : "None"}\` Mention: <@&${role.id}> (\`<@&${role.id}>\`) `), });