diff options
-rw-r--r-- | bot/decorators.py | 14 | ||||
-rw-r--r-- | bot/exts/moderation/infraction/infractions.py | 16 | ||||
-rw-r--r-- | bot/exts/moderation/infraction/management.py | 4 |
3 files changed, 17 insertions, 17 deletions
diff --git a/bot/decorators.py b/bot/decorators.py index dd001d3ca..a0390fc32 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -240,14 +240,14 @@ def mock_in_debug(return_value: t.Any) -> t.Callable: return decorator -def ensure_duration_in_future(duration_arg: function.Argument) -> t.Callable: +def ensure_future_timestamp(timestamp_arg: function.Argument) -> t.Callable: """ - Ensure the duration argument is in the future. + Ensure the timestamp argument is in the future. - If the condition fails, a warning is sent to the invoking context. + If the condition fails, send a warning to the invoking context. - `duration_arg` is the keyword name or position index of the parameter of the decorated command - whose value is the target duration. + `timestamp_arg` is the keyword name or position index of the parameter of the decorated command + whose value is the target timestamp. This decorator must go before (below) the `command` decorator. """ @@ -255,12 +255,12 @@ def ensure_duration_in_future(duration_arg: function.Argument) -> t.Callable: @command_wraps(func) async def wrapper(*args, **kwargs) -> t.Any: bound_args = function.get_bound_args(func, args, kwargs) - target = function.get_arg_value(duration_arg, bound_args) + target = function.get_arg_value(timestamp_arg, bound_args) ctx = function.get_arg_value(1, bound_args) if isinstance(target, datetime) and target < arrow.utcnow(): - await ctx.send(":x: Expiration is in the past.") + await ctx.send(":x: Provided timestamp is in the past.") return return await func(*args, **kwargs) diff --git a/bot/exts/moderation/infraction/infractions.py b/bot/exts/moderation/infraction/infractions.py index 09610cb1a..18bed5080 100644 --- a/bot/exts/moderation/infraction/infractions.py +++ b/bot/exts/moderation/infraction/infractions.py @@ -10,7 +10,7 @@ from bot import constants from bot.bot import Bot from bot.constants import Event from bot.converters import Age, Duration, Expiry, MemberOrUser, UnambiguousMemberOrUser -from bot.decorators import ensure_duration_in_future, respect_role_hierarchy +from bot.decorators import ensure_future_timestamp, respect_role_hierarchy from bot.exts.moderation.infraction import _utils from bot.exts.moderation.infraction._scheduler import InfractionScheduler from bot.log import get_logger @@ -81,7 +81,7 @@ class Infractions(InfractionScheduler, commands.Cog): await self.apply_kick(ctx, user, reason) @command() - @ensure_duration_in_future(duration_arg=3) + @ensure_future_timestamp(timestamp_arg=3) async def ban( self, ctx: Context, @@ -98,7 +98,7 @@ class Infractions(InfractionScheduler, commands.Cog): await self.apply_ban(ctx, user, reason, expires_at=duration) @command(aliases=("cban", "purgeban", "pban")) - @ensure_duration_in_future(duration_arg=3) + @ensure_future_timestamp(timestamp_arg=3) async def cleanban( self, ctx: Context, @@ -163,7 +163,7 @@ class Infractions(InfractionScheduler, commands.Cog): await ctx.send(":x: This command is not yet implemented. Maybe you meant to use `voicemute`?") @command(aliases=("vmute",)) - @ensure_duration_in_future(duration_arg=3) + @ensure_future_timestamp(timestamp_arg=3) async def voicemute( self, ctx: Context, @@ -183,7 +183,7 @@ class Infractions(InfractionScheduler, commands.Cog): # region: Temporary infractions @command(aliases=["mute"]) - @ensure_duration_in_future(duration_arg=3) + @ensure_future_timestamp(timestamp_arg=3) async def tempmute( self, ctx: Context, user: UnambiguousMemberOrUser, @@ -217,7 +217,7 @@ class Infractions(InfractionScheduler, commands.Cog): await self.apply_mute(ctx, user, reason, expires_at=duration) @command(aliases=("tban",)) - @ensure_duration_in_future(duration_arg=3) + @ensure_future_timestamp(timestamp_arg=3) async def tempban( self, ctx: Context, @@ -253,7 +253,7 @@ class Infractions(InfractionScheduler, commands.Cog): await ctx.send(":x: This command is not yet implemented. Maybe you meant to use `tempvoicemute`?") @command(aliases=("tempvmute", "tvmute")) - @ensure_duration_in_future(duration_arg=3) + @ensure_future_timestamp(timestamp_arg=3) async def tempvoicemute( self, ctx: Context, @@ -300,7 +300,7 @@ class Infractions(InfractionScheduler, commands.Cog): # region: Temporary shadow infractions @command(hidden=True, aliases=["shadowtempban", "stempban", "stban"]) - @ensure_duration_in_future(duration_arg=3) + @ensure_future_timestamp(timestamp_arg=3) async def shadow_tempban( self, ctx: Context, diff --git a/bot/exts/moderation/infraction/management.py b/bot/exts/moderation/infraction/management.py index 4ec1039af..842cdabcd 100644 --- a/bot/exts/moderation/infraction/management.py +++ b/bot/exts/moderation/infraction/management.py @@ -9,7 +9,7 @@ from discord.utils import escape_markdown from bot import constants from bot.bot import Bot from bot.converters import Expiry, Infraction, MemberOrUser, Snowflake, UnambiguousUser, allowed_strings -from bot.decorators import ensure_duration_in_future +from bot.decorators import ensure_future_timestamp from bot.errors import InvalidInfraction from bot.exts.moderation.infraction.infractions import Infractions from bot.exts.moderation.modlog import ModLog @@ -100,7 +100,7 @@ class ModManagement(commands.Cog): await self.infraction_edit(ctx, infraction, duration, reason=reason) @infraction_group.command(name='edit', aliases=('e',)) - @ensure_duration_in_future(duration_arg=3) + @ensure_future_timestamp(timestamp_arg=3) async def infraction_edit( self, ctx: Context, |