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 { filterRolesFromMemberUpdate } from "../helper/roleFilter"
|
||||||
import { ChangedRoles, PermissionLevel } from "../interfaces"
|
import { ChangedRoles, PermissionLevel } from "../interfaces"
|
||||||
import { jellyfinHandler } from "../.."
|
import { jellyfinHandler } from "../.."
|
||||||
|
import { v4 as uuid } from "uuid"
|
||||||
|
|
||||||
export const name = 'guildMemberUpdate'
|
export const name = 'guildMemberUpdate'
|
||||||
export async function execute(oldMember: GuildMember, newMember: GuildMember) {
|
export async function execute(oldMember: GuildMember, newMember: GuildMember) {
|
||||||
try {
|
try {
|
||||||
|
const requestId = uuid()
|
||||||
const changedRoles: ChangedRoles = filterRolesFromMemberUpdate(oldMember, newMember)
|
const changedRoles: ChangedRoles = filterRolesFromMemberUpdate(oldMember, newMember)
|
||||||
const triggerRoleIds: Collection<string, PermissionLevel> = getGuildSpecificTriggerRoleId(oldMember.guild.id)
|
const triggerRoleIds: Collection<string, PermissionLevel> = getGuildSpecificTriggerRoleId(oldMember.guild.id)
|
||||||
|
|
||||||
triggerRoleIds.forEach((level, key) => {
|
triggerRoleIds.forEach((level, key) => {
|
||||||
const addedRoleMatches = changedRoles.addedRoles.find(aRole => aRole.id === key)
|
const addedRoleMatches = changedRoles.addedRoles.find(aRole => aRole.id === key)
|
||||||
if (addedRoleMatches) {
|
if (addedRoleMatches) {
|
||||||
jellyfinHandler.upsertUser(newMember, level)
|
jellyfinHandler.upsertUser(newMember, level, requestId)
|
||||||
}
|
}
|
||||||
const removedRoleMatches = changedRoles.removedRoles.find(rRole => rRole.id === key)
|
const removedRoleMatches = changedRoles.removedRoles.find(rRole => rRole.id === key)
|
||||||
if (removedRoleMatches) {
|
if (removedRoleMatches) {
|
||||||
jellyfinHandler.removeUser(newMember)
|
jellyfinHandler.removeUser(newMember, requestId)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user