automod: use proper locks in removeRoles action

This commit is contained in:
Dragory 2021-02-14 17:16:00 +02:00
parent 0c27795fd9
commit 6bb6dfadb9
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -66,11 +66,15 @@ export const RemoveRolesAction = automodAction({
return;
}
const memberRolesLock = await pluginData.locks.acquire(`member-roles-${member.id}`);
const rolesArr = Array.from(memberRoles.values());
await member.edit({
roles: rolesArr,
});
member.roles = rolesArr; // Make sure we know of the new roles internally as well
memberRolesLock.unlock();
}),
);
},