Add multiple username match message on unban, fix len(filter) error
This commit is contained in:
parent
5e7b46e0e8
commit
65c6bf5996
1 changed files with 19 additions and 5 deletions
|
@ -195,12 +195,26 @@ class AdminCog(commands.Cog):
|
|||
bans,
|
||||
)
|
||||
else:
|
||||
results = filter(lambda x: x.user.name == user, bans)
|
||||
results = [
|
||||
x for x in filter(lambda x: x.user.name == user, bans)
|
||||
]
|
||||
if results:
|
||||
if len(results) > 1:
|
||||
# TODO: send list of bans that matched
|
||||
# for admins to use on next attempt
|
||||
pass
|
||||
active_bans = []
|
||||
for ban in bans:
|
||||
active_bans.append(
|
||||
"{0} ({1}): {2}".format(
|
||||
ban.user.name, ban.user.id, ban.reason
|
||||
)
|
||||
)
|
||||
message = (
|
||||
"More than one result. "
|
||||
+ "Please use one of the following IDs:\n```"
|
||||
+ "\n".join(active_bans)
|
||||
+ "\n```"
|
||||
)
|
||||
await ctx.send(message)
|
||||
return
|
||||
else:
|
||||
discord_ban_info = results[0]
|
||||
|
||||
|
@ -308,7 +322,7 @@ class AdminCog(commands.Cog):
|
|||
user = await self.bot.fetch_user(ban["user"])
|
||||
ban["username"] = user.name if user else "[deleted user]"
|
||||
ban_messages.append(
|
||||
"[{0}] {1} ({2}): {3}\n".format(
|
||||
"[{0}] {1} ({2}): {3}".format(
|
||||
ban["time"].strftime("%d-%m-%Y"),
|
||||
ban["username"],
|
||||
ban["user"],
|
||||
|
|
Loading…
Add table
Reference in a new issue