Intuitively handle limit
This commit is contained in:
parent
a21fcdeec5
commit
bfd3f75836
24
cogs/mod.py
24
cogs/mod.py
|
@ -511,7 +511,7 @@ class Mod:
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@utils.custom_perms(manage_messages=True)
|
@utils.custom_perms(manage_messages=True)
|
||||||
async def prune(self, ctx, limit=None):
|
async def prune(self, ctx, *specifications=None):
|
||||||
"""This command can be used to prune messages from certain members
|
"""This command can be used to prune messages from certain members
|
||||||
Mention any user you want to prune messages from; if no members are mentioned, the messages removed will be mine
|
Mention any user you want to prune messages from; if no members are mentioned, the messages removed will be mine
|
||||||
If no limit is provided, then 100 will be used. This is also the max limit we can use
|
If no limit is provided, then 100 will be used. This is also the max limit we can use
|
||||||
|
@ -519,18 +519,16 @@ class Mod:
|
||||||
EXAMPLE: !prune 50
|
EXAMPLE: !prune 50
|
||||||
RESULT: 50 of my messages are removed from this channel"""
|
RESULT: 50 of my messages are removed from this channel"""
|
||||||
# We can only get logs from 100 messages at a time, so make sure we are not above that threshold
|
# We can only get logs from 100 messages at a time, so make sure we are not above that threshold
|
||||||
try:
|
limit = 100
|
||||||
# We may not have been passed a limit, and only mentions
|
for x in specifications:
|
||||||
# If this happens, the limit will be set to that first mention
|
try:
|
||||||
limit = int(limit)
|
limit = int(limit)
|
||||||
except (TypeError, ValueError):
|
if limit <= 100:
|
||||||
limit = 100
|
break
|
||||||
|
else:
|
||||||
if limit > 100:
|
limit = 100
|
||||||
limit = 100
|
except (TypeError, ValueError):
|
||||||
if limit < 0:
|
continue
|
||||||
await ctx.send("Limit cannot be less than 0!")
|
|
||||||
return
|
|
||||||
|
|
||||||
# If no members are provided, assume we're trying to prune our own messages
|
# If no members are provided, assume we're trying to prune our own messages
|
||||||
members = ctx.message.mentions
|
members = ctx.message.mentions
|
||||||
|
|
Loading…
Reference in a new issue