|
|
|
@ -50,22 +50,27 @@ const bot = new Client({ intents: [
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
var retryCounter = 0;
|
|
|
|
|
(function login()
|
|
|
|
|
function login()
|
|
|
|
|
{
|
|
|
|
|
bot.login(process.env.discord_token).catch(()=>
|
|
|
|
|
{
|
|
|
|
|
if(retryCounter==900) return startLimitProtectionTimer();
|
|
|
|
|
console.log('Server: Falhou o login', retryCounter)
|
|
|
|
|
if(retryCounter>=900) return startLimitProtectionTimer();
|
|
|
|
|
login();
|
|
|
|
|
retryCounter++;
|
|
|
|
|
});
|
|
|
|
|
})()
|
|
|
|
|
}
|
|
|
|
|
login();
|
|
|
|
|
function startLimitProtectionTimer()
|
|
|
|
|
{
|
|
|
|
|
console.log('Server: Rate Limit Protection - Waiting before trying again.')
|
|
|
|
|
console.log('Server: Rate Limit Protection - Sending notification')
|
|
|
|
|
sendNotification('Server Rate Limit Protection - Something broke.');
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
login();
|
|
|
|
|
retryCounter = 0;
|
|
|
|
|
}, 60*60*1000);
|
|
|
|
|
console.log('Server: Rate Limit Protection Reset');
|
|
|
|
|
sendNotification('Nothing was fixed but it will try again.');
|
|
|
|
|
login();
|
|
|
|
|
}, 24*60*60*1000);
|
|
|
|
|
}
|
|
|
|
|
function connectToDB()
|
|
|
|
|
{
|
|
|
|
@ -198,4 +203,16 @@ function moveAFKs(){
|
|
|
|
|
async function serversWithMusicOn()
|
|
|
|
|
{
|
|
|
|
|
return await GuildM.find({music:true}).then(g=>{return g})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function sendNotification(message)
|
|
|
|
|
{
|
|
|
|
|
fetch('https://ntfy.wordfights.com/RemChanv2',{
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
'Accept': 'application/json',
|
|
|
|
|
},
|
|
|
|
|
body: message
|
|
|
|
|
} )
|
|
|
|
|
}
|