From 2c5b85bba7f245c61905d5272444fc83329e3c1e Mon Sep 17 00:00:00 2001 From: ionite34 Date: Wed, 3 Aug 2022 13:50:58 -0400 Subject: Updated `purge` to require >1 users --- bot/exts/moderation/clean.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bot/exts/moderation/clean.py b/bot/exts/moderation/clean.py index d7c2c7673..a6104d91c 100644 --- a/bot/exts/moderation/clean.py +++ b/bot/exts/moderation/clean.py @@ -7,7 +7,7 @@ from datetime import datetime from itertools import takewhile from typing import Callable, Iterable, Literal, Optional, TYPE_CHECKING, Union -from discord import Colour, Message, NotFound, TextChannel, Thread, User, errors +from discord import Colour, Embed, Message, NotFound, TextChannel, Thread, User, errors from discord.ext.commands import Cog, Context, Converter, Greedy, command, group, has_any_role from discord.ext.commands.converter import TextChannelConverter from discord.ext.commands.errors import BadArgument @@ -627,12 +627,18 @@ class Clean(Cog): @command() async def purge(self, ctx: Context, users: Greedy[User], age: Optional[Union[Age, ISODateTime]] = None) -> None: """ - Clean messages of users from all public channels up to a certain message age (10 minutes by default). + Clean messages of `users` from all public channels up to a certain message `age` (10 minutes by default). - The age is *exclusive*, meaning that `10s` won't delete a message exactly 10 seconds old. + Requires 1 or more users to be specified. For channel-based cleaning, use `clean` instead. + + The `age` is *exclusive*, meaning that `10s` won't delete a message exactly 10 seconds old. """ + if not users: + raise BadArgument("At least one user must be specified.") + if age is None: age = await Age().convert(ctx, "10M") + await self._clean_messages(ctx, channels="*", users=users, first_limit=age) # endregion -- cgit v1.2.3 From 2d16b21988dc71992c325bbc3e8f87284f3d5918 Mon Sep 17 00:00:00 2001 From: ionite34 Date: Wed, 3 Aug 2022 13:56:02 -0400 Subject: Removed unused import --- bot/exts/moderation/clean.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/exts/moderation/clean.py b/bot/exts/moderation/clean.py index a6104d91c..8f2a1e3db 100644 --- a/bot/exts/moderation/clean.py +++ b/bot/exts/moderation/clean.py @@ -7,7 +7,7 @@ from datetime import datetime from itertools import takewhile from typing import Callable, Iterable, Literal, Optional, TYPE_CHECKING, Union -from discord import Colour, Embed, Message, NotFound, TextChannel, Thread, User, errors +from discord import Colour, Message, NotFound, TextChannel, Thread, User, errors from discord.ext.commands import Cog, Context, Converter, Greedy, command, group, has_any_role from discord.ext.commands.converter import TextChannelConverter from discord.ext.commands.errors import BadArgument -- cgit v1.2.3 From 87de12cfdcf9e5028e62f24bbbdd357496a4683f Mon Sep 17 00:00:00 2001 From: ionite34 Date: Wed, 3 Aug 2022 14:32:37 -0400 Subject: Improved `purge` help message --- bot/exts/moderation/clean.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/exts/moderation/clean.py b/bot/exts/moderation/clean.py index 8f2a1e3db..748c018d2 100644 --- a/bot/exts/moderation/clean.py +++ b/bot/exts/moderation/clean.py @@ -631,7 +631,7 @@ class Clean(Cog): Requires 1 or more users to be specified. For channel-based cleaning, use `clean` instead. - The `age` is *exclusive*, meaning that `10s` won't delete a message exactly 10 seconds old. + `age` can be a duration or an ISO 8601 timestamp. """ if not users: raise BadArgument("At least one user must be specified.") -- cgit v1.2.3