[MassUnban] Add typing indicator

This commit is contained in:
aikaterna
2021-09-30 16:29:33 -07:00
parent 3c89fcf463
commit 6871ec09ae

View File

@@ -56,21 +56,23 @@ class MassUnban(commands.Cog):
try: try:
await self.bot.wait_for("message", check=pred, timeout=15) await self.bot.wait_for("message", check=pred, timeout=15)
if pred.result is True: if pred.result is True:
for ban_entry in banlist: async with ctx.typing():
await ctx.guild.unban(ban_entry.user, reason=f"Mass Unban requested by {str(ctx.author)} ({ctx.author.id})") for ban_entry in banlist:
await asyncio.sleep(0.5) await ctx.guild.unban(ban_entry.user, reason=f"Mass Unban requested by {str(ctx.author)} ({ctx.author.id})")
unban_count += 1 await asyncio.sleep(0.5)
unban_count += 1
else: else:
return await ctx.send("Alright, I'm not unbanning everyone.") return await ctx.send("Alright, I'm not unbanning everyone.")
except asyncio.TimeoutError: except asyncio.TimeoutError:
return await ctx.send("Response timed out. Please run this command again if you wish to try again.") return await ctx.send("Response timed out. Please run this command again if you wish to try again.")
else: else:
for ban_entry in banlist: async with ctx.typing():
if not ban_entry.reason: for ban_entry in banlist:
continue if not ban_entry.reason:
if ban_reason.lower() in ban_entry.reason.lower(): continue
await ctx.guild.unban(ban_entry.user, reason=f"Mass Unban requested by {str(ctx.author)} ({ctx.author.id})") if ban_reason.lower() in ban_entry.reason.lower():
await asyncio.sleep(0.5) await ctx.guild.unban(ban_entry.user, reason=f"Mass Unban requested by {str(ctx.author)} ({ctx.author.id})")
unban_count += 1 await asyncio.sleep(0.5)
unban_count += 1
await ctx.send(f"Done. Unbanned {unban_count} users.") await ctx.send(f"Done. Unbanned {unban_count} users.")