From 2c8152606c520e18d1401e9c56da0a4ffb381865 Mon Sep 17 00:00:00 2001 From: Michael H Date: Tue, 27 Aug 2019 18:45:56 -0400 Subject: [PATCH] [Modlog] Reduce potential for bad API calls (#2945) - brings a fix over from #2934 --- changelog.d/modlog/2945.fix.rst | 1 + redbot/core/modlog.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelog.d/modlog/2945.fix.rst diff --git a/changelog.d/modlog/2945.fix.rst b/changelog.d/modlog/2945.fix.rst new file mode 100644 index 000000000..a30222b30 --- /dev/null +++ b/changelog.d/modlog/2945.fix.rst @@ -0,0 +1 @@ +Remove potential for additional bad API calls per ban/unban diff --git a/redbot/core/modlog.py b/redbot/core/modlog.py index 8a1a03bd6..27d6901e3 100644 --- a/redbot/core/modlog.py +++ b/redbot/core/modlog.py @@ -74,7 +74,8 @@ async def _init(bot: Red): await asyncio.sleep(10) # prevent small delays from causing a 5 minute delay on entry attempts = 0 - while attempts < 12: # wait up to an hour to find a matching case + # wait up to an hour to find a matching case + while attempts < 12 and guild.me.guild_permissions.view_audit_log: attempts += 1 try: entry = await guild.audit_logs( @@ -109,7 +110,8 @@ async def _init(bot: Red): await asyncio.sleep(10) # prevent small delays from causing a 5 minute delay on entry attempts = 0 - while attempts < 12: # wait up to an hour to find a matching case + # wait up to an hour to find a matching case + while attempts < 12 and guild.me.guild_permissions.view_audit_log: attempts += 1 try: entry = await guild.audit_logs(