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(