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")