From f6476c609b394be5482cce38f6f7f701253c97c6 Mon Sep 17 00:00:00 2001 From: kenobi Date: Sun, 25 Jun 2023 22:47:06 +0200 Subject: [PATCH] fetch members of roleId from guild --- server/helper/roleFilter.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/helper/roleFilter.ts b/server/helper/roleFilter.ts index 23ea237..02df4da 100644 --- a/server/helper/roleFilter.ts +++ b/server/helper/roleFilter.ts @@ -1,5 +1,5 @@ -import { Collection, GuildMember } from "discord.js" -import { ChangedRoles, PermissionLevel } from "../interfaces" +import { Collection, Guild, GuildMember, Role, User } from "discord.js" +import { ChangedRoles, Maybe, PermissionLevel } from "../interfaces" import { logger } from "../logger" import { config } from "../configuration" @@ -16,6 +16,13 @@ export function filterRolesFromMemberUpdate(oldMember: GuildMember, newMember: G return { addedRoles, removedRoles } } +export async function getMembersWithRoleFromGuild(roleId: string, guild: Guild): Promise> { + const emptyResponse = new Collection + const guildRole: Maybe = guild.roles.resolve(roleId) + if (!guildRole) return emptyResponse + return guildRole.members +} + export function getGuildSpecificTriggerRoleId(): Collection { const outVal = new Collection() outVal.set(config.bot.watcher_role, "VIEWER")