Repository: Cog-Creators/Red-DiscordBot

Issue:
Cleanup Between addition
# Feature request

Cleanup between messageID1 messageID2


#### Select the type of feature you are requesting:

<!-- To check a box, replace the space between the [] with a x -->

- [ ] Cog
- [X] Command
- [ ] API functionality

#### Describe your requested feature
Adding onto the Cleanup Cog from Core. The ability to cleanup messages that are between two messagsIDs, will be a reliable way to know what message you're deleting rather than trying to just guess with the other commands.



Discussion:

Resolving patch:
diff --git a/redbot/cogs/cleanup/cleanup.py b/redbot/cogs/cleanup/cleanup.py
--- a/redbot/cogs/cleanup/cleanup.py
+++ b/redbot/cogs/cleanup/cleanup.py
@@ -10,6 +10,7 @@
 from redbot.core.utils.mod import slow_deletion, mass_purge
 from redbot.cogs.mod.log import log
 from redbot.core.utils.predicates import MessagePredicate
+from .converters import RawMessageIds
 
 _ = Translator("Cleanup", __file__)
 
@@ -211,7 +212,9 @@ def check(m):
     @cleanup.command()
     @commands.guild_only()
     @commands.bot_has_permissions(manage_messages=True)
-    async def after(self, ctx: commands.Context, message_id: int, delete_pinned: bool = False):
+    async def after(
+        self, ctx: commands.Context, message_id: RawMessageIds, delete_pinned: bool = False
+    ):
         """Delete all messages after a specified message.
 
         To get a message id, enable developer mode in Discord's
@@ -242,7 +245,11 @@ async def after(self, ctx: commands.Context, message_id: int, delete_pinned: boo
     @commands.guild_only()
     @commands.bot_has_permissions(manage_messages=True)
     async def before(
-        self, ctx: commands.Context, message_id: int, number: int, delete_pinned: bool = False
+        self,
+        ctx: commands.Context,
+        message_id: RawMessageIds,
+        number: int,
+        delete_pinned: bool = False,
     ):
         """Deletes X messages before specified message.
 
@@ -271,6 +278,48 @@ async def before(
 
         await mass_purge(to_delete, channel)
 
+    @cleanup.command()
+    @commands.guild_only()
+    @commands.bot_has_permissions(manage_messages=True)
+    async def between(
+        self,
+        ctx: commands.Context,
+        one: RawMessageIds,
+        two: RawMessageIds,
+        delete_pinned: bool = False,
+    ):
+        """Delete the messages between Messsage One and Message Two, providing the messages IDs.
+
+        The first message ID should be the older message and the second one the newer.
+
+        Example:
+            `[p]cleanup between 123456789123456789 987654321987654321`
+        """
+        channel = ctx.channel
+        author = ctx.author
+        try:
+            mone = await channel.fetch_message(one)
+        except discord.errors.Notfound:
+            return await ctx.send(
+                _("Could not find a message with the ID of {id}.".format(id=one))
+            )
+        try:
+            mtwo = await channel.fetch_message(two)
+        except discord.errors.Notfound:
+            return await ctx.send(
+                _("Could not find a message with the ID of {id}.".format(id=two))
+            )
+        to_delete = await self.get_messages_for_deletion(
+            channel=channel, before=mtwo, after=mone, delete_pinned=delete_pinned
+        )
+        to_delete.append(ctx.message)
+        reason = "{}({}) deleted {} messages in channel {}.".format(
+            author.name, author.id, len(to_delete), channel.name
+        )
+        log.info(reason)
+
+        await mass_purge(to_delete, channel)
+
     @cleanup.command()
     @commands.guild_only()
     @commands.bot_has_permissions(manage_messages=True)
diff --git a/redbot/cogs/cleanup/converters.py b/redbot/cogs/cleanup/converters.py
new file mode 100644
--- /dev/null
+++ b/redbot/cogs/cleanup/converters.py
@@ -0,0 +1,12 @@
+from redbot.core.commands import Converter, BadArgument
+from redbot.core.i18n import Translator
+
+_ = Translator("Cleanup", __file__)
+
+
+class RawMessageIds(Converter):
+    async def convert(self, ctx, argument):
+        if argument.isnumeric() and len(argument) >= 17:
+            return int(argument)
+
+        raise BadArgument(_("{} doesn't look like a valid message ID.").format(argument))


Test patch: