12brendan3 / UC-Esports-Bot

A bot for the University of Cincinnati Esports Discord server. Written using discord.js.
MIT License
3 stars 0 forks source link

Role statistics command #12

Closed 12brendan3 closed 3 years ago

12brendan3 commented 3 years ago

A command for the bot to reply with statistics about a role should be created. The command should return role member count, role name, role color, and percent of users with the role.

Code that works for getting the member count is:

let split = msg.content.split[' '];
await msg.guild.members.fetch();
let role = guild.roles.cache.find(role => role.name == split[1]);
msg.reply(`there are ${role.members.size} members with the ${split[1]} role.`);

The content of the message in this case is something like bc!rolemembers Bearcat. We would need to use something other than a space or use substr since a role's name may contain a space.