Skip to content

Commit

Permalink
Add member list to roleinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Glazelf committed Jan 17, 2025
1 parent 023fc0b commit 3370179
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions commands/info/roleinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ export default async (interaction, messageFlags) => {

let guildMembers = await interaction.guild.members.fetch().catch(e => { return null; });
if (!guildMembers) return;
let memberCount = guildMembers.filter(member => member.roles.cache.get(role.id)).size;
let roleMembers = guildMembers.filter(member => member.roles.cache.get(role.id));
let roleMembersString = "";
for (const [id, member] of roleMembers) {
let stringAddition = member.toString();
if (roleMembersString.length > 0) stringAddition = `, ${member}`;
if (roleMembersString.length + stringAddition.length < 1021) { // Limit is 1024, 1021 used so that dots in else statement always fit
roleMembersString += stringAddition;
} else {
roleMembersString += "...";
break;
};
};
// Properties
let roleProperties = "";
if (role.hoist) roleProperties = `${roleProperties}Sorted seperately\n`;
Expand All @@ -38,10 +49,10 @@ export default async (interaction, messageFlags) => {
.addFields([{ name: "Role:", value: role.toString(), inline: true }]);
if (role.hexColor !== defaultColor) roleEmbed.addFields([{ name: "Color:", value: role.hexColor, inline: true }]);
roleEmbed.addFields([
{ name: "Members:", value: memberCount.toString(), inline: true },
{ name: "Position:", value: role.rawPosition.toString(), inline: true },
{ name: "Properties:", value: roleProperties, inline: false },
{ name: "Permissions:", value: permissionString, inline: false }
{ name: "Permissions:", value: permissionString, inline: false },
{ name: `Members: (${roleMembers.size})`, value: roleMembersString, inline: false },
]);
return sendMessage({ interaction: interaction, embeds: roleEmbed, flags: messageFlags });
};
Expand Down

0 comments on commit 3370179

Please sign in to comment.