Skip to content

Commit

Permalink
Add delay to the main process function
Browse files Browse the repository at this point in the history
  • Loading branch information
0x16c3 committed Apr 18, 2022
1 parent 35a01f3 commit 4aac57d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cogs/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,9 @@ async def on_ready(self):
)

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

logger.info(f"Loaded {len(self.feeds)}.")
self.loaded = True
Expand All @@ -462,7 +462,7 @@ async def process(self):

await asyncio.sleep(int(config["INTERVAL"]))

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

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

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

@cog_ext.cog_slash(
name="activity",
description="Setup / manage an activity feed in the current channel.",
Expand Down

0 comments on commit 4aac57d

Please sign in to comment.