Skip to content

Commit

Permalink
fix(network): add a 1s wait every 50 sends
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 committed Jan 26, 2024
1 parent 6f0649d commit aaa0382
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/managers/NetworkManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { connectedList, hubs, originalMessages } from '@prisma/client';
import { LINKS, REGEX, emojis } from '../utils/Constants.js';
import { check as checkProfanity, censor } from '../utils/Profanity.js';
import { HubSettingsBitField } from '../utils/BitFields.js';
import { parseTimestampFromId, replaceLinks } from '../utils/Utils.js';
import { parseTimestampFromId, replaceLinks, wait } from '../utils/Utils.js';
import { t } from '../utils/Locale.js';
import Logger from '../utils/Logger.js';

Expand Down Expand Up @@ -155,7 +155,10 @@ export default class NetworkManager extends Factory {
embedCol: (isNetworkMessage.embedColor as HexColorString) ?? undefined,
});

const sendResult = allConnections.map(async (connection) => {
const sendResult = allConnections.map(async (connection, index) => {
// wait 1 second every 50 messages to avoid rate limits
if (index % 50) await wait(1000);

try {
// parse the webhook url and get the webhook id and token
// fetch the webhook from discord
Expand Down

0 comments on commit aaa0382

Please sign in to comment.