diff --git a/README.md b/README.md
index ef4bfba7..5b8ad94f 100644
--- a/README.md
+++ b/README.md
@@ -51,7 +51,7 @@ You can contact me in the Red 3rd party server in #support_flare-cogs
| R6 | 1.6.0 | Show R6 Statistics.
List R6 Statistics from seasons, individual operators, all operators and more! | flare(flare#0001) |
| RedditPost | 0.6.0 | Reddit Autoposting of new content.
| flare(flare#0001) |
| RoleHistory | 0.1.0 | Visualize the history of a user's roles.
| flare(flare#0001) |
-| Snipe | 0.5.0 | Snipe the last message deleted in a channel.
Snipe command converted to Red, get the last message deleted in a channel. | flare(flare#0001) |
+| Snipe | 0.6.0 | Snipe the last message deleted in a channel.
Snipe command converted to Red, get the last message deleted in a channel. | flare(flare#0001) |
| StickBugged | 0.0.1 | Get stickbugged.
| flare(flare#0001) |
| ThreadBumper | 0.0.1 | Bump threads to keep them alive forever.
| flare(flare#0001) |
| trigger | 0.2.2 | Allow for the creation of triggers to respond to keywords in messages.
| flare(flare#0001) |
diff --git a/snipe/snipe.py b/snipe/snipe.py
index fc14a897..cfaae60c 100644
--- a/snipe/snipe.py
+++ b/snipe/snipe.py
@@ -20,7 +20,7 @@
class Snipe(commands.Cog):
"""Snipe the last message from a server."""
- __version__ = "0.5.0"
+ __version__ = "0.6.0"
def format_help_for_context(self, ctx):
"""Thanks Sinbad."""
@@ -236,6 +236,36 @@ async def snipe(
embeds.append(embed)
await self.reply(ctx, embeds=embeds)
+ @commands.guild_only()
+ @commands.cooldown(rate=1, per=5, type=commands.BucketType.channel)
+ @commands.bot_has_permissions(embed_links=True)
+ async def clearsnipes(self, ctx, type: str = "delete"):
+ """Clears snipes from the current channel by the current user."""
+ guild: discord.Guild = ctx.guild
+ if not await self.config.guild(guild).toggle():
+ await self.reply(
+ ctx,
+ f"Sniping is not allowed in this server! An admin may turn it on by typing `{ctx.clean_prefix}snipeset enable true`.",
+ )
+ return
+
+ cache = self.delete_cache if type == "delete" else self.edit_cache
+ if cache[guild.id].get(ctx.channel.id) is None:
+ await self.reply(ctx, "There's nothing to clear!")
+ return
+
+ author_id = ctx.author.id
+ snipes = []
+ for snipe in cache[guild.id][ctx.channel.id]:
+ if snipe["author"] == author_id:
+ snipes.append(snipe)
+ if not snipes:
+ await self.reply(ctx, "There's nothing to clear!")
+ return
+ for snipe in snipes:
+ cache[guild.id][ctx.channel.id].remove(snipe)
+ await self.reply(ctx, f"{len(snipes)} snipes cleared.")
+
@staticmethod
def get_content(content: str, limit: int = 1024):
return content if len(content) <= limit else f"{content[:limit - 3]}..."