EnelGy Posted September 27, 2020 Report Share Posted September 27, 2020 I set some sessionExpired function, that reconnect the bot to steam when its expired. But when it expires, it reconnect the bot multiple times. The command below send about 20 messages that theres an error, and the error is fixed. Also in console it looks like (picture). Does anyone know wheres the problem ? community.on("sessionExpired", function(err) { client.channels.cache.get("753653286283903126").send('<:false:750799883572609245> **There was an error, fixing the error... <:repairing:755511536423927909>**') .then(sentMessage => sentMessage.delete({ timeout: 4000 })) .catch(console.error) client.channels.cache.get("753653286283903126").send('<:true:750799921497505913> **Error is fixed, you can try again !**') .then(sentMessage => sentMessage.delete({ timeout: 4500 })) .catch(console.error) client.channels.cache.get("753653286283903126").updateOverwrite(message.guild.roles.everyone, { SEND_MESSAGES: true }) .then(channel => console.log('Channel unmute')) .catch(console.error); if (client2.steamID == undefined) { client2.logOn(logInOptions); client2.on('loggedOn', () => { console.log('Steam Bot is running !'); client2.setPersona(SteamUser.EPersonaState.Online); client2.gamesPlayed(440); }); } else { client2.webLogOn(); //relogin to Steam or refresh tradeoffer-manager cookies } //add your handling code here, for example: if (sendofferError == true){ //do stuff } }) Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted September 28, 2020 Report Share Posted September 28, 2020 You're adding a new loggedOn event listener every time you log on, so it's going to get called multiple times. You should only have one loggedOn listener. Also you probably don't need to call logOn in the sessionExpired event since steam-user automatically attempts to log back on when it gets disconnected, unless the error event gets emitted. Quote Link to comment Share on other sites More sharing options...
EnelGy Posted September 30, 2020 Author Report Share Posted September 30, 2020 what do you mean "one loggedOn listener" ?? Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted October 1, 2020 Report Share Posted October 1, 2020 Every time you call .on('loggedOn', ...), you're adding a new event listener. When the event gets emitted, each function you passed to .on will be called, which can be multiple. Quote Link to comment Share on other sites More sharing options...
EnelGy Posted October 1, 2020 Author Report Share Posted October 1, 2020 and how could I reduce the multiple calling ? Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted October 2, 2020 Report Share Posted October 2, 2020 Don't call it multiple times. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.