right now I am struggling to find a way to set a minimum amount of messages that can be purged. Basically I want it so whenever someone uses the command it will send an error for typing 0 or nothing for amount. I tried some things but they did not seem to work so I guess someone in here will know how to help me.
The code is this:
@commands.command()
@commands.has_permissions(manage_messages=True)
async def clear(self, ctx, *, limit=None):
await ctx.message.delete()
channel = ctx.channel
messages = await channel.history(limit=123).flatten()
if limit != 0 or None:
if not messages:
await ctx.channel.send("I am really sorry but I can not purge an empty channel!")
return
else:
try:
await channel.purge(limit = limit)
return
except discord.Forbidden:
return await ctx.channel.send('I do not have perms')
else:
ctx.channel.send('Minimum amount of purge is 1!')
return
In the beginning I had the limit=None
to limit=100
and the None in the if limit != 0 or None
was not working. Now I changed it but whenever I put any number that has nothing to do with 0 or None it does not work. Any ideas why and how to fix it?