add function to filter the role changes from member update
This commit is contained in:
parent
92d8f805b6
commit
c28b37b0e9
16
server/helper/roleFilter.ts
Normal file
16
server/helper/roleFilter.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { GuildMember } from "discord.js"
|
||||
import { ChangedRoles } from "../interfaces"
|
||||
import { logger } from "../logger"
|
||||
|
||||
export function filterRolesFromMemberUpdate(oldMember: GuildMember, newMember: GuildMember): ChangedRoles {
|
||||
|
||||
const oldRoles = oldMember.roles.cache
|
||||
const newRoles = newMember.roles.cache
|
||||
|
||||
const removedRoles = oldRoles.filter(x => newRoles.find(y => y.id === x.id) == undefined)
|
||||
const addedRoles = newRoles.filter(x => oldRoles.find(y => y.id === x.id) == undefined)
|
||||
logger.info(`Member ${oldMember.id} RemovedRoles: ${removedRoles.map(x => x.name)}`, { guildId: oldMember.guild.id })
|
||||
logger.info(`Member ${oldMember.id} AddedRoles: ${addedRoles.map(x => x.name)}`, { guildId: oldMember.guild.id })
|
||||
|
||||
return { addedRoles, removedRoles }
|
||||
}
|
Loading…
Reference in New Issue
Block a user