diff --git a/server.js b/server.js index ef844cc..7bc152c 100644 --- a/server.js +++ b/server.js @@ -49,11 +49,24 @@ const bot = new Client({ intents: [ Partials.Message ] }); +var retryCounter = 0; (function login() { - bot.login(process.env.discord_token).catch(()=>{login()}); + bot.login(process.env.discord_token).catch(()=> + { + if(retryCounter==900) return startLimitProtectionTimer(); + login(); + retryCounter++; + }); })() - +function startLimitProtectionTimer() +{ + console.log('Server: Rate Limit Protection - Waiting before trying again.') + setTimeout(() => { + login(); + retryCounter = 0; + }, 30*60*1000); +} function connectToDB() { try {