Skip to content

Commit

Permalink
[WarnSystem] Use fetch_ban endpoint (#198)
Browse files Browse the repository at this point in the history
* [warnsystem] use fetch_ban endpoint

* fix AttributeError
  • Loading branch information
Zephyrkul committed Jun 17, 2022
1 parent bc6bc2d commit b98e6b7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions warnsystem/warnsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,18 +1290,21 @@ async def wsunmute(self, ctx: commands.Context, member: discord.Member):
await ctx.send(page)

@commands.command()
@commands.bot_has_permissions(ban_members=True)
@checks.mod_or_permissions(ban_members=True)
async def wsunban(self, ctx: commands.Context, member: UnavailableMember):
async def wsunban(self, ctx: commands.Context, member_id: int):
"""
Unban a member banned with WarnSystem.
*wsunban = WarnSystem unban. Feel free to add an alias.*
"""
guild = ctx.guild
bans = await guild.bans()
if member.id not in [x.user.id for x in bans]:
try:
ban_entry = await guild.fetch_ban(discord.Object(member_id))
except discord.NotFound:
await ctx.send(_("That user is not banned."))
return
member = ban_entry.user
try:
await guild.unban(member)
except discord.errors.HTTPException as e:
Expand Down

0 comments on commit b98e6b7

Please sign in to comment.