diff --git a/.gitignore b/.gitignore index c2658d7..cb3152d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules/ +participants.csv diff --git a/index.js b/index.js index b81eae1..0647fd2 100644 --- a/index.js +++ b/index.js @@ -44,10 +44,15 @@ client.on("message", async message => { async function usersWithRole(message) { if (message.content.split(" ")[1].length < 3) { message.reply("query must contain at least 3 characters!") + return; } - const roles = message.guild.roles.cache.filter(role => role.name.includes(message.content.split(" ")[1])); - console.log(message.content.split(" ")[1]); - console.log(roles.size); + const roles = message.guild.roles.cache.filter(role => role.name.toLowerCase().includes(message.content.split(" ")[1])); + const roleEmbed = new Discord.MessageEmbed() + .setTitle(`${roles.array()[0].members.array().length} users with the role \`${roles.array()[0].name}\`:`) + .setDescription(" • " + roles.array()[0].members.map(m => m.user.tag).join('\n\n • ')) + .setFooter(`Role ID: ${roles.array()[0].id}`) + .setTimestamp(); + message.channel.send(roleEmbed); } async function aboutServer(message) {