fetch members of roleId from guild

This commit is contained in:
kenobi 2023-06-25 22:47:06 +02:00
parent 6220268b14
commit f6476c609b

View File

@ -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<Collection<string, GuildMember>> {
const emptyResponse = new Collection<string, GuildMember>
const guildRole: Maybe<Role> = guild.roles.resolve(roleId)
if (!guildRole) return emptyResponse
return guildRole.members
}
export function getGuildSpecificTriggerRoleId(): Collection<string, PermissionLevel> {
const outVal = new Collection<string, PermissionLevel>()
outVal.set(config.bot.watcher_role, "VIEWER")