Skip to content

Commit 778ee7c

Browse files
committed
Pixl - deleteall command
1 parent b297ea2 commit 778ee7c

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

pixl/pixl.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Pixl(commands.Cog):
4848
"""
4949

5050
__author__ = "[vertyco](https://github.com/vertyco/vrt-cogs)"
51-
__version__ = "0.3.8"
51+
__version__ = "0.3.9"
5252

5353
def __init__(self, bot: Red, *args, **kwargs):
5454
super().__init__(*args, **kwargs)
@@ -705,6 +705,28 @@ async def add_image(self, ctx: commands.Context, url: Optional[str], *, answers:
705705
embed.set_image(url=url)
706706
await ctx.send(embed=embed)
707707

708+
@image.command(name="deleteall")
709+
@commands.bot_has_permissions(embed_links=True)
710+
async def delete_all_images(self, ctx: commands.Context, confirm: bool):
711+
"""
712+
Delete all custom images for this guild
713+
714+
This will remove all custom images that have been added to this guild.
715+
Default and global images will remain available if enabled.
716+
"""
717+
guild_images = await self.config.guild(ctx.guild).images()
718+
if not guild_images or len(guild_images) < 1:
719+
return await ctx.send("There are no guild images to delete")
720+
721+
if confirm:
722+
# User confirmed, delete all images
723+
async with ctx.typing():
724+
await self.config.guild(ctx.guild).images.set([])
725+
await ctx.send(f"Successfully deleted all {len(guild_images)} custom images for this guild")
726+
else:
727+
# User cancelled
728+
await ctx.send("Run this command again with `confirm=True` to delete all custom images")
729+
708730
# -/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/ METHODS -/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
709731
async def image_menu(
710732
self,

0 commit comments

Comments
 (0)