Skip to content

Commit 791bb8e

Browse files
committed
refactor: updated _fetch_with_retries to use logic from filterign #55
1 parent 695206e commit 791bb8e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

bot/exts/moderation/infraction/superstarify.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,19 @@ async def _fetch_with_retries(self,
241241
retries: int = URLs.connect_max_retries,
242242
params: dict[str, str] | None = None) -> list[dict]:
243243
"""Fetch infractions from the API with retries and exponential backoff."""
244-
for attempt in range(retries):
244+
if retries < 1:
245+
raise ValueError("retries must be at least 1")
246+
247+
for attempt in range(1, retries + 1):
245248
try:
246249
return await self.bot.api_client.get("bot/infractions", params=params)
247250
except Exception as e:
248-
if attempt == retries - 1 or not is_retryable_api_error(e):
251+
if attempt == retries or not is_retryable_api_error(e):
249252
raise
250253
await asyncio.sleep(URLs.connect_initial_backoff * (2 ** (attempt - 1)))
251254
return None
252255

256+
253257
async def setup(bot: Bot) -> None:
254258
"""Load the Superstarify cog."""
255259
await bot.add_cog(Superstarify(bot))

0 commit comments

Comments
 (0)