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

#### v1.7.1 #### v1.7.1
###### New Features ###### New Features
- `warn purge` added to clear warn list of banned users. - `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 #### v1.7.0
###### New Features ###### New Features

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

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


user_id = str(user.id) user_id = str(user.id)
async def purge(self, ctx, dry_run=0): 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.""" """Purges banned users from the warn list. Add a 1 at the end to do a dry run."""
settings = gs.get(ctx.guild) settings = gs.get(ctx.guild)
warnings = settings.warnings.copy()
count = 0 count = 0
for ban in await ctx.guild.bans(): 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) settings.warnings.pop(user)
count += 1 count += 1
settings.update(settings.warnings, "warnings")
return await ctx.send("Purged {} banned users from the warn list.".format(count)) return await ctx.send("Purged {} banned users from the warn list.".format(count))


@commands.has_permissions(kick_members=True) @commands.has_permissions(kick_members=True)

Loading…
Cancel
Save