R3v3rso Posted November 27, 2018 Report Posted November 27, 2018 Hello everyone !So I spent the last few weeks trying to create a bot that basically trades random steam cards for Steam Game Keys (with a lot of help from Vanilla ;p ) I am now pretty much done with all the trading stuff, and the last thing that I need is to get the Steam Key from my file. Basically, my goal is to- Count how many keys in total are in my .txt or .csv or .anything file and get that to a variable so I can add a line earlier in the code which checks if i have enough keys left before accepting the cards- Get the key(s) from the file (in order to send them in chat)-move the used keys to another file or modify their line to mark them as 'inactive' or something. Here is the part where I stopped : else { totalKeyWeGive = cardCount / cardToKey; console.log("We will give "+totalKeyWeGive+ " SteamKey"); offer.accept(); console.log("OFFER ACCEPTED"); //loop on how much we give the key for (i = 0; i < totalKeyWeGive; i++) { //get steamkey from file here ---------------------------------------------------------------------------- } var textMsg = "Hello ! You bought "+totalKeyWeGive+ " Game keys. Your keys are: "; } client.chatMessage(offer.partner.getSteamID64(), textMsg); } I already have most of the variables setup, and processed earlier in the code : cardToKey - How many cards are needed for one keycardCount - How many cards are there in the offertotalKeyWeGive - If everything is okay in the trade, how many keys should we give Any advices on how I should handle this ? Quote
Dr. McKay Posted November 27, 2018 Report Posted November 27, 2018 The first problem I see is that you aren't handling the callback to offer.accept, which could fail. Secondly, you can use the fs module to read from a file. If it's newline-delimited, you could call split("\n") to get an array containing each line in the file. R3v3rso 1 Quote
R3v3rso Posted November 28, 2018 Author Report Posted November 28, 2018 Oh yeah I forgot to add that, so it should be offer.accept(offer) right ? Thanks for the suggestion. I'll look into that ! Have a nice day Quote
Dr. McKay Posted November 29, 2018 Report Posted November 29, 2018 Oh yeah I forgot to add that, so it should be offer.accept(offer) right ? No, that's not right. Quote
R3v3rso Posted December 2, 2018 Author Report Posted December 2, 2018 Then how should I handle the callback ? I'm currently getting errors on offer.decline(offer) , while offer.accept(offer) is fully working ? (btw I finally managed to make something functional out of the fs module, thank you for the advice !) Quote
Dr. McKay Posted December 3, 2018 Report Posted December 3, 2018 offer.accept(function(err) { if (err) { // handle error } }); Quote
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.