Jump to content
McKay Development

Recommended Posts

Posted

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 }
})

image.png.6ceef1a9e9dacc359ffdc523cd3a5f37.png

Posted

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.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...