From 74836493011b16af40e51bc9b2b01b4f3f4d50e5 Mon Sep 17 00:00:00 2001 From: hendraaagil Date: Sun, 14 Jan 2024 00:12:46 +0700 Subject: [PATCH 1/2] feat: filter out admin from helper list --- commands/helper-list.command.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/commands/helper-list.command.js b/commands/helper-list.command.js index acb8dd6..7e9070a 100644 --- a/commands/helper-list.command.js +++ b/commands/helper-list.command.js @@ -17,6 +17,8 @@ exports.permissions = [ }, ]; +const filterOutAdmin = (member) => !member.roles.cache.some((role) => JSON.parse(process.env.ROLE).includes(role.id)); + exports.execute = async (interaction) => { await interaction.deferReply(); @@ -45,7 +47,8 @@ exports.execute = async (interaction) => { const roleName = interaction.guild.roles.cache.get(helperRole.role_id).name; const members = interaction.guild.roles.cache .get(helperRole.role_id) - .members.map((member) => member.user.id); + .members.filter((member) => filterOutAdmin(member)) + .map((member) => member.user.id); const listMembers = members.length ? members.map((member) => `- <@${member}>`).join('\n') : '- No one here :('; @@ -62,7 +65,10 @@ exports.execute = async (interaction) => { return await interaction.editReply({ content: 'Role not found!' }); } - const roleMemberIds = interaction.guild.roles.cache.get(role.id).members.map((member) => member.user.id); + const roleMemberIds = interaction.guild.roles.cache + .get(role.id) + .members.filter((member) => filterOutAdmin(member)) + .map((member) => member.user.id); const members = await Promise.all( roleMemberIds.map(async (memberId) => { const [firstMessage, lastMessage, lastMessageCountIn30Days] = await Promise.all([ From edf61c57446dfed04a7f5e322538170ae7f5c474 Mon Sep 17 00:00:00 2001 From: hendraaagil Date: Sun, 14 Jan 2024 00:21:02 +0700 Subject: [PATCH 2/2] fix: filter total member --- commands/helper-list.command.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/commands/helper-list.command.js b/commands/helper-list.command.js index 7e9070a..dcc2690 100644 --- a/commands/helper-list.command.js +++ b/commands/helper-list.command.js @@ -31,7 +31,9 @@ exports.execute = async (interaction) => { let totalMember = 0; allHelperRoles.forEach((helperRole) => { - totalMember += interaction.guild.roles.cache.get(helperRole.role_id).members.size; + totalMember += interaction.guild.roles.cache + .get(helperRole.role_id) + .members.filter((member) => filterOutAdmin(member)).size; }); const allHelperEmbed = new MessageEmbed()