mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
Enforce unified lock names by using functions to generate lock keys (#165)
This commit is contained in:
parent
fcbb25b7ff
commit
c5d68650a3
18 changed files with 70 additions and 28 deletions
|
@ -1,6 +1,7 @@
|
|||
import { mutesEvt } from "../types";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { stripObjectToScalars } from "../../../utils";
|
||||
import { memberRolesLock } from "../../../utils/lockNameHelpers";
|
||||
|
||||
/**
|
||||
* Reapply active mutes on join
|
||||
|
@ -11,9 +12,9 @@ export const ReapplyActiveMuteOnJoinEvt = mutesEvt("guildMemberAdd", async ({ pl
|
|||
const muteRole = pluginData.config.get().mute_role;
|
||||
|
||||
if (muteRole) {
|
||||
const memberRolesLock = await pluginData.locks.acquire(`member-roles-${member.id}`);
|
||||
const memberRoleLock = await pluginData.locks.acquire(memberRolesLock(member));
|
||||
await member.addRole(muteRole);
|
||||
memberRolesLock.unlock();
|
||||
memberRoleLock.unlock();
|
||||
}
|
||||
|
||||
pluginData.state.serverLogs.log(LogType.MEMBER_MUTE_REJOIN, {
|
||||
|
|
|
@ -17,8 +17,8 @@ import { CasesPlugin } from "../../Cases/CasesPlugin";
|
|||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { Case } from "../../../data/entities/Case";
|
||||
import { sendErrorMessage } from "src/pluginUtils";
|
||||
import { LogsPlugin } from "src/plugins/Logs/LogsPlugin";
|
||||
import { LogsPlugin } from "../../../plugins/Logs/LogsPlugin";
|
||||
import { muteLock } from "../../../utils/lockNameHelpers";
|
||||
|
||||
export async function muteUser(
|
||||
pluginData: GuildPluginData<MutesPluginType>,
|
||||
|
@ -29,7 +29,7 @@ export async function muteUser(
|
|||
removeRolesOnMuteOverride: boolean | string[] | null = null,
|
||||
restoreRolesOnMuteOverride: boolean | string[] | null = null,
|
||||
) {
|
||||
const lock = await pluginData.locks.acquire(`mute-${userId}`);
|
||||
const lock = await pluginData.locks.acquire(muteLock({ id: userId }));
|
||||
|
||||
const muteRole = pluginData.config.get().mute_role;
|
||||
if (!muteRole) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue