You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mines, a bit inefficient, but it gets the job done
// add this to near top to allow request module to be addedconstrequest=require('request')// put the two variables below autotipSession// Make sure to replace "INSERT_YOUR_UUID_HERE" with the uuid you want to check if they're onlineconstapiEndpoint=`https://api.hypixel.net/status?uuid=INSERT_YOUR_UUID_HERE`;// i created a variable called hypixelKey in credentials.json but you can just put it in hereconstapiKey=credentials.hypixelKey;// put the below under onMessage() functionasyncfunctioncheckSessionStatus(){returnnewPromise((resolve)=>{request.get({url: apiEndpoint,headers: {'Api-Key': apiKey},json: true},(error,response,body)=>{if(error){console.error('Error:',error);resolve(false);}constsession=body.session;if(session&&session.online){console.log('Player is online. Waiting for 5 minutes...');resolve(true);}else{console.log('Player is offline. Logging in to the server...');resolve(false);}});});}
You'd also want to replace the init function.
asyncfunctionmain(){// Checks if player is onlineonline=awaitcheckSessionStatus()if(online==false){bot=mineflayer.createBot(options);bot._client.once('session',session=>options.session=session);bot.once('login',onLogin);bot.on('message',onMessage);bot.on('kicked',(reason)=>{logger.info(`Kicked for ${reason}`);});bot.once('end',()=>{// Schedule the main function to run again after 3 minutes of bot exitingsetTimeout(main,3*60*1000);});}else{// If the player is not online, recheck after 5 minutessetTimeout(main,5*60*1000);}}
When the player logs into hypixel, we get kicked with this message:
When that happens, wait 5 minutes and check hypixel API for player online status.
https://api.hypixel.net/#tag/Player-Data/paths/~1status/get
If the user is online, just wait another 5 minutes.
If it says the user is offline, we can reconnect and continue.
node-autotip/index.js
Line 146 in 97b0d66
The text was updated successfully, but these errors were encountered: