3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-19 16:05:01 +00:00

Add a shared lock for Persist and ReactionRoles plugins to prevent race conditions

This commit is contained in:
Dragory 2020-05-22 20:35:15 +03:00
parent 19b54360a4
commit 3264ce1f14
2 changed files with 14 additions and 3 deletions

View file

@ -71,8 +71,13 @@ export class PersistPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.event("guildMemberAdd")
async onGuildMemberAdd(_, member: Member) {
const memberRolesLock = await this.locks.acquire(`member-roles-${member.id}`);
const persistedData = await this.persistedData.find(member.id);
if (!persistedData) return;
if (!persistedData) {
memberRolesLock.unlock();
return;
}
const toRestore: MemberOptions = {};
const config = this.getConfig();
@ -101,5 +106,7 @@ export class PersistPlugin extends ZeppelinPlugin<TConfigSchema> {
restoredData: restoredData.join(", "),
});
}
memberRolesLock.unlock();
}
}