From d9fca4cb8f52a1ba245bd4c626ed62006bae7f86 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Thu, 1 Apr 2021 23:09:54 +0000 Subject: [PATCH] Add role querys and add participants.csv to .gitignore --- .gitignore | 1 + index.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) 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 4eee181..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); + 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) {