Add assigning Référent role

This commit is contained in:
pikiou 2023-03-21 22:48:47 +01:00
parent 90571c59ea
commit ca52d1a108

View File

@ -286,7 +286,7 @@ async function setAllRoles(client: Client) {
: "" : ""
) )
const referentRoleIds: { [key: string]: string } = _.mapValues(teamIds, (v) => const teamReferentRoleIds: { [key: string]: string } = _.mapValues(teamIds, (v) =>
_.isEmpty(v) _.isEmpty(v)
? "" ? ""
: guild.roles.cache.find((role) => role.name === `Référent-${v}`)?.id || "" : guild.roles.cache.find((role) => role.name === `Référent-${v}`)?.id || ""
@ -295,13 +295,26 @@ async function setAllRoles(client: Client) {
await setVolunteersRoles( await setVolunteersRoles(
guild, guild,
volunteerByDiscordIdNoOrga, volunteerByDiscordIdNoOrga,
referentRoleIds, teamReferentRoleIds,
(volunteer: Volunteer) => (volunteer: Volunteer) =>
_.includes(["oui", "peut-etre", "à distance"], volunteer.active) && _.includes(["oui", "peut-etre", "à distance"], volunteer.active) &&
volunteer.roles.includes("référent") volunteer.roles.includes("référent")
? `${volunteer.team}` ? `${volunteer.team}`
: "0" : "0"
) )
const referentRoleId = guild.roles.cache.find((role) => role.name === `Référent`)?.id
await setVolunteersRoles(
guild,
volunteerByDiscordIdNoOrga,
referentRoleId ? { ref: referentRoleId } : {},
(volunteer: Volunteer) =>
_.includes(["oui", "peut-etre", "à distance"], volunteer.active) &&
volunteer.roles.includes("référent")
? "ref"
: ""
)
} catch (error) { } catch (error) {
console.error("Error in setAllRoles", error) console.error("Error in setAllRoles", error)
} }