Browse Source

fixed error in purge command and list command

tags/v1.7.1
Roxie Gibson 6 years ago
parent
commit
edb4e90f67
2 changed files with 9 additions and 3 deletions
  1. +2
    -0
      README.md
  2. +7
    -3
      roxbot/cogs/admin.py

+ 2
- 0
README.md View File

@@ -18,6 +18,8 @@ _Coming Soon_
#### v1.7.1
###### New Features
- `warn purge` added to clear warn list of banned users.
###### Bug Fixes
- `warn list` no longer returns error when the list is empty.

#### v1.7.0
###### New Features

+ 7
- 3
roxbot/cogs/admin.py View File

@@ -145,6 +145,8 @@ class Admin():
else:
output += "{}: {} Warning(s)\n".format(member, len(
settings.warnings[member]))
if not output:
return await ctx.send("No warnings on record.")
return await ctx.send(output)

user_id = str(user.id)
@@ -210,13 +212,15 @@ class Admin():
async def purge(self, ctx, dry_run=0):
"""Purges banned users from the warn list. Add a 1 at the end to do a dry run."""
settings = gs.get(ctx.guild)
warnings = settings.warnings.copy()
count = 0
for ban in await ctx.guild.bans():
for user in settings.warnings:
if user == ban.user.id:
if not dry_run:
for user in warnings:
if int(user) == ban.user.id:
if dry_run == 0:
settings.warnings.pop(user)
count += 1
settings.update(settings.warnings, "warnings")
return await ctx.send("Purged {} banned users from the warn list.".format(count))

@commands.has_permissions(kick_members=True)

Loading…
Cancel
Save