Made purge command work properly

pull/8/head
sgoudham 4 years ago
parent e24da2dfc8
commit b4a883f0ee

@ -80,16 +80,19 @@ class Moderation(commands.Cog):
@bot_has_guild_permissions(manage_messages=True) @bot_has_guild_permissions(manage_messages=True)
async def purge(self, ctx, amount: int = None): async def purge(self, ctx, amount: int = None):
"""Purge Messages from Channel""" """Purge Messages from Channel"""
if amount:
if 0 < amount <= 100: if 0 < amount <= 100:
with ctx.channel.typing(): with ctx.channel.typing():
await ctx.message.delete() await ctx.message.delete()
deleted = await ctx.channel.purge(limit=amount, after=datetime.datetime.utcnow() - timedelta(days=14)) deleted = await ctx.channel.purge(limit=amount + 1,
after=datetime.datetime.utcnow() - timedelta(days=14))
await ctx.send(f"Deleted **{len(deleted):,}** messages.", delete_after=5) await ctx.send(f"Deleted **{len(deleted):,}** messages.", delete_after=5)
else: else:
await ctx.send("The amount provided is not between **0** and **100**") await ctx.send("The amount provided is not between **0** and **100**")
else:
await ctx.send("**You must specify an amount!**")
def setup(bot): def setup(bot):

Loading…
Cancel
Save