Skip to content

Commit

Permalink
Add log for rate limit delay
Browse files Browse the repository at this point in the history
  • Loading branch information
0x16c3 committed Apr 18, 2022
1 parent 1284fdd commit 35a01f3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cogs/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ async def on_ready(self):

error_channel_ids = []

for i, item in enumerate(items):
for item in items:
channel: discord.TextChannel = self.client.get_channel(int(item["channel"]))

if item in self.feeds:
Expand Down Expand Up @@ -428,11 +428,7 @@ async def on_ready(self):

self.feeds.append(user)

# wait 60 seconds after every 40 feed to prevent rate limiting
if i % 40 == 0:
await asyncio.sleep(30)

for user in self.feeds:
for i, user in enumerate(self.feeds):
user: Activity

enable_filter = not user.channel.is_nsfw()
Expand All @@ -446,6 +442,11 @@ async def on_ready(self):
activity=user,
)

# wait 60 seconds after every 30 feeds to prevent rate limiting
if i % 30 == 0:
logger.info(f"Waiting 60 seconds.")
await asyncio.sleep(30)

logger.info(f"Loaded {len(self.feeds)}.")
self.loaded = True
del error_channel_ids
Expand Down

0 comments on commit 35a01f3

Please sign in to comment.