finally use request id
This commit is contained in:
parent
5db37b0e95
commit
7e37641e0b
@ -2,22 +2,23 @@ import { Collection, GuildMember } from "discord.js"
|
||||
import { filterRolesFromMemberUpdate } from "../helper/roleFilter"
|
||||
import { ChangedRoles, PermissionLevel } from "../interfaces"
|
||||
import { jellyfinHandler } from "../.."
|
||||
import { v4 as uuid } from "uuid"
|
||||
|
||||
export const name = 'guildMemberUpdate'
|
||||
export async function execute(oldMember: GuildMember, newMember: GuildMember) {
|
||||
try {
|
||||
|
||||
const requestId = uuid()
|
||||
const changedRoles: ChangedRoles = filterRolesFromMemberUpdate(oldMember, newMember)
|
||||
const triggerRoleIds: Collection<string, PermissionLevel> = getGuildSpecificTriggerRoleId(oldMember.guild.id)
|
||||
|
||||
triggerRoleIds.forEach((level, key) => {
|
||||
const addedRoleMatches = changedRoles.addedRoles.find(aRole => aRole.id === key)
|
||||
if (addedRoleMatches) {
|
||||
jellyfinHandler.upsertUser(newMember, level)
|
||||
jellyfinHandler.upsertUser(newMember, level, requestId)
|
||||
}
|
||||
const removedRoleMatches = changedRoles.removedRoles.find(rRole => rRole.id === key)
|
||||
if (removedRoleMatches) {
|
||||
jellyfinHandler.removeUser(newMember)
|
||||
jellyfinHandler.removeUser(newMember, requestId)
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
|
Loading…
Reference in New Issue
Block a user