Skip to content

Commit

Permalink
Add a small delay between tweets being sent to Discord
Browse files Browse the repository at this point in the history
  • Loading branch information
MattIPv4 committed Jan 9, 2022
1 parent fe838f8 commit 55ec7a0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global TWEETS_TO_DISCORD_LAST_TWEET */

const WorkersSentry = require('workers-sentry/worker');
const htmlEntities = require('html-entities');

Expand Down Expand Up @@ -102,10 +104,14 @@ const mirrorLatestTweets = async () => {

// Process each tweet
for (const tweet of tweets) {
// Send the tweet to Discord
console.log(await processTweet(tweet, data.includes).then(res => res.text()));

// Store this as the most recent tweet we've processed
await TWEETS_TO_DISCORD_LAST_TWEET.put('latest_id', tweet.id);

// Wait a bit to avoid hitting the rate limit
await new Promise(resolve => setTimeout(resolve, 250));
}
};

Expand Down

0 comments on commit 55ec7a0

Please sign in to comment.