diff options
author | 2022-06-11 19:33:13 +0300 | |
---|---|---|
committer | 2022-06-11 19:33:26 +0300 | |
commit | 49c89472a08491b847c82d4cc27b1b54080daa93 (patch) | |
tree | 536c6c591256901d75db34469c520f69715f2be3 | |
parent | Fix clean range not being exclusive (diff) |
Add user purging command
The command cleans all public messages from a user. This is a private case that is common enough that it probably deserves a shortcut.
Since the `purge` alias is never used for the clean group I repurposed it for this new command.
-rw-r--r-- | bot/exts/moderation/clean.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/bot/exts/moderation/clean.py b/bot/exts/moderation/clean.py index 123148e02..5a3481067 100644 --- a/bot/exts/moderation/clean.py +++ b/bot/exts/moderation/clean.py @@ -8,7 +8,7 @@ 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.ext.commands import Cog, Context, Converter, Greedy, group, has_any_role +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 @@ -452,7 +452,7 @@ class Clean(Cog): # region: Commands - @group(invoke_without_command=True, name="clean", aliases=["clear", "purge"]) + @group(invoke_without_command=True, name="clean", aliases=("clear",)) async def clean_group( self, ctx: Context, @@ -619,6 +619,13 @@ class Clean(Cog): await self._send_expiring_message(ctx, message) await self._delete_invocation(ctx) + @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).""" + if age is None: + age = await Age().convert(ctx, "10M") + await self._clean_messages(ctx, channels="*", users=users, first_limit=age) + # endregion async def cog_check(self, ctx: Context) -> bool: |