diff options
| -rw-r--r-- | bot/cogs/reminders.py | 8 | ||||
| -rw-r--r-- | bot/decorators.py | 15 | 
2 files changed, 9 insertions, 14 deletions
| diff --git a/bot/cogs/reminders.py b/bot/cogs/reminders.py index be97d34b6..734e0bd2d 100644 --- a/bot/cogs/reminders.py +++ b/bot/cogs/reminders.py @@ -14,7 +14,7 @@ from discord.ext.commands import Cog, Context, Greedy, group  from bot.bot import Bot  from bot.constants import Guild, Icons, MODERATION_ROLES, POSITIVE_REPLIES, STAFF_ROLES  from bot.converters import Duration -from bot.decorators import mutually_exclusive_arg +from bot.decorators import lock_arg  from bot.pagination import LinePaginator  from bot.utils.checks import without_role_check  from bot.utils.messages import send_denial @@ -166,7 +166,7 @@ class Reminders(Cog):          log.trace(f"Scheduling new task #{reminder['id']}")          self.schedule_reminder(reminder) -    @mutually_exclusive_arg(NAMESPACE, "reminder", itemgetter("id"), raise_error=True) +    @lock_arg(NAMESPACE, "reminder", itemgetter("id"), raise_error=True)      async def send_reminder(self, reminder: dict, late: relativedelta = None) -> None:          """Send the reminder."""          is_valid, user, channel = self.ensure_valid_reminder(reminder) @@ -373,7 +373,7 @@ class Reminders(Cog):          mention_ids = [mention.id for mention in mentions]          await self.edit_reminder(ctx, id_, {"mentions": mention_ids}) -    @mutually_exclusive_arg(NAMESPACE, "id_", raise_error=True) +    @lock_arg(NAMESPACE, "id_", raise_error=True)      async def edit_reminder(self, ctx: Context, id_: int, payload: dict) -> None:          """Edits a reminder with the given payload, then sends a confirmation message."""          reminder = await self._edit_reminder(id_, payload) @@ -391,7 +391,7 @@ class Reminders(Cog):          await self._reschedule_reminder(reminder)      @remind_group.command("delete", aliases=("remove", "cancel")) -    @mutually_exclusive_arg(NAMESPACE, "id_", raise_error=True) +    @lock_arg(NAMESPACE, "id_", raise_error=True)      async def delete_reminder(self, ctx: Context, id_: int) -> None:          """Delete one of your active reminders."""          await self.bot.api_client.delete(f"bot/reminders/{id_}") diff --git a/bot/decorators.py b/bot/decorators.py index 333716cf5..aabbe2cc9 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -66,12 +66,7 @@ def without_role(*role_ids: int) -> t.Callable:      return check(predicate) -def mutually_exclusive( -    namespace: t.Hashable, -    resource_id: ResourceId, -    *, -    raise_error: bool = False, -) -> t.Callable: +def lock(namespace: t.Hashable, resource_id: ResourceId, *, raise_error: bool = False) -> t.Callable:      """      Turn the decorated coroutine function into a mutually exclusive operation on a `resource_id`. @@ -126,7 +121,7 @@ def mutually_exclusive(      return decorator -def mutually_exclusive_arg( +def lock_arg(      namespace: t.Hashable,      name_or_pos: function.Argument,      func: t.Callable[[t.Any], _IdCallableReturn] = None, @@ -134,12 +129,12 @@ def mutually_exclusive_arg(      raise_error: bool = False,  ) -> t.Callable:      """ -    Apply `mutually_exclusive` using the value of the arg at the given name/position as the ID. +    Apply the `lock` decorator using the value of the arg at the given name/position as the ID.      `func` is an optional callable or awaitable which will return the ID given the argument value. -    See `mutually_exclusive` docs for more information. +    See `lock` docs for more information.      """ -    decorator_func = partial(mutually_exclusive, namespace, raise_error=raise_error) +    decorator_func = partial(lock, namespace, raise_error=raise_error)      return function.get_arg_value_wrapper(decorator_func, name_or_pos, func) | 
