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
|
@ -6,6 +6,7 @@ import { splitRoleNames } from "../util/splitRoleNames";
|
|||
import { normalizeRoleNames } from "../util/normalizeRoleNames";
|
||||
import { findMatchingRoles } from "../util/findMatchingRoles";
|
||||
import { Role } from "eris";
|
||||
import { memberRolesLock } from "../../../utils/lockNameHelpers";
|
||||
|
||||
export const RoleAddCmd = selfGrantableRolesCmd({
|
||||
trigger: ["role", "role add"],
|
||||
|
@ -16,7 +17,7 @@ export const RoleAddCmd = selfGrantableRolesCmd({
|
|||
},
|
||||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
const lock = await pluginData.locks.acquire(`grantableRoles:${msg.author.id}`);
|
||||
const lock = await pluginData.locks.acquire(memberRolesLock(msg.author));
|
||||
|
||||
const applyingEntries = getApplyingEntries(pluginData, msg);
|
||||
if (applyingEntries.length === 0) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
|||
import { splitRoleNames } from "../util/splitRoleNames";
|
||||
import { normalizeRoleNames } from "../util/normalizeRoleNames";
|
||||
import { findMatchingRoles } from "../util/findMatchingRoles";
|
||||
import { memberRolesLock } from "../../../utils/lockNameHelpers";
|
||||
|
||||
export const RoleRemoveCmd = selfGrantableRolesCmd({
|
||||
trigger: "role remove",
|
||||
|
@ -15,7 +16,7 @@ export const RoleRemoveCmd = selfGrantableRolesCmd({
|
|||
},
|
||||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
const lock = await pluginData.locks.acquire(`grantableRoles:${msg.author.id}`);
|
||||
const lock = await pluginData.locks.acquire(memberRolesLock(msg.author));
|
||||
|
||||
const applyingEntries = getApplyingEntries(pluginData, msg);
|
||||
if (applyingEntries.length === 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue