Jump to content
McKay Development

TextDynasty

Member
  • Posts

    144
  • Joined

  • Last visited

Posts posted by TextDynasty

  1. You'll need to retrieve the offer first.

     if (message.substring(0,8) == '!accept '){
        var offerid = message.substring(8);
        manager.getOffer(offerid, function(offer) {
            offer.accept(false, function(error, status) {
                if (error) {
                    logger.error(`| OFFER RECEIVED |: ID#${offer.id} has failed trying to accept it. Reason: Offer is no longer valid.`);
                    return;
                } else if (status === 'pending') {
                    logger.info(`| OFFER NEEDS CONFIRM | : ID#${offer.id} is accepted but needs confirmation`);
                    community.acceptConfirmationForObject(config.identity_secret, offer.id);
                }
            })
        })
      }

    Is this what you mean by getOffer?

     

    It has this error

            offer.accept(false, function(error, status) {
                  ^
    
    TypeError: Cannot read property 'accept' of null
        at C:\Users\lokin\OneDrive\桌面\item933\app.js:188:15
        at Helpers.checkNeededDescriptions (C:\Users\lokin\OneDrive\桌面\item933\node_modules\steam-tradeoffer-manager\lib\index.js:437:4)
        at Object.exports.checkNeededDescriptions (C:\Users\lokin\OneDrive\桌面\item933\node_modules\steam-tradeoffer-manager\lib\helpers.js:90:3)
        at _apiCall (C:\Users\lokin\OneDrive\桌面\item933\node_modules\steam-tradeoffer-manager\lib\index.js:431:11)
        at SteamCommunity._community.httpRequest (C:\Users\lokin\OneDrive\桌面\item933\node_modules\steam-tradeoffer-manager\lib\webapi.js:61:3)
        at Request._callback (C:\Users\lokin\OneDrive\桌面\item933\node_modules\steamcommunity\components\http.js:67:15)
        at Request.self.callback (C:\Users\lokin\OneDrive\桌面\item933\node_modules\request\request.js:185:22)
        at Request.emit (events.js:182:13)
        at Request.<anonymous> (C:\Users\lokin\OneDrive\桌面\item933\node_modules\request\request.js:1161:10)
        at Request.emit (events.js:182:13)
    Press any key to continue . . .
    
  2. Hi, so I wrote a few codes to my bot to make it send me a message with offer id included once there's a need for the background check. But I don't know how or is there a way to make it accept the trade offer through providing the trade offer id to the bot.

    const parseAdminMessage = (message) =>{
     if (message.substring(0,8) == '!accept '){
        var offerid = message.substring(8);
        console.log(offerid); //It can show the correct offerid here but i dont know how to make it accept the trade by the offerid
    }
    
    //This is what I used to accept normal trade offer with the offer status
    
    const acceptTradeOffer = (offer) => {
        offer.accept(false, function(error, status) {
            if (error) {
                logger.error(`| OFFER RECEIVED |: ID#${offer.id} has failed trying to accept it. Reason: Offer is no longer valid.`);
                return 'Badass';
            } else if (status === 'pending') {
                logger.info(`| OFFER NEEDS CONFIRM | : ID#${offer.id} is accepted but needs confirmation`);
                var confCount = 0;
                function confirm(idSecret, idOffer) {
                    community.acceptConfirmationForObject(idSecret, idOffer, function(error) {
                        confCount++
                        if (error) {
                            if (confCount < 4) {
                                confirm(idSecret, idOffer);
                            } else {
                              logger.error(error);
                                logger.fail(`| OFFER RECEIVED | : ID#${offer.id} has failed trying to confirm it. Reason: Offer is no longer valid.`);
                                return 'done';
                            }
                        } else {
                            return 'done';
                        }
                    });
                }
                confirm(config.identity_secret, offer.id);
            } else {
                return 'done';
            }
        });
    }
    
  3. Is there a way to set a variable of the price by using this package?

     

    https://github.com/tarikkiziltan/getPrice

     

    I saw there's

    var Price = require("./getprice.js")
    //var price = new Price(tag,craft,item,callBack) // What should i put in the callback if i want to use the price? Thanks
    
    
    Price.getPrice("Vintage","Craftable","Gunslinger",function(price,priceType) {
    	console.log("It's " + price + " " + priceType);
    }) 
    
  4. Need Some Help with the problem

    { Error: The request is a duplicate and the action has already occurred in the past, ignored this time
    

    The Code i am using

    function craftScrap(){
    	manager.getInventoryContents(440, 2, true, function (err, inventory){
    		if (err) {
    			console.log(err);
    		} else {
    			var rec = inventory.filter(function (item) {
    				return item.name == "Reclaimed Metal"
    			});
    			var ref = inventory.filter(function (item) {
    				return item.name == "Refined Metal"
    			});
    			var recCount = rec.length;
    			var refCount = ref.length;
    			
    			if (recCount || refCount > 0){
    				console.log("User can smelt metals");
    				if(recCount == 0){
    					for (let i = 0; i < refCount; i++) {
    						tf2.craft([ref[i].id]);
    					}
    					manager.getInventoryContents(440, 2, true, function (err, inventory){
    						var rec1 = inventory.filter(function (item) {
    							return item.name == "Reclaimed Metal"
    						});
    						var rec1Count = rec1.length;
    						for (let i = 0; i < rec1Count; i++) {
    							tf2.craft([rec1[i].id]);
    						}
    					})
    				} else {
    					for (let i = 0; i < recCount; i++) {
    						tf2.craft([rec[i].id]);
    					}
    				}
    			} else {
    				console.log("No metal to smelt");
    				return;
    			}
    		}
    	})
    }
    
  5. You need to pass craft an array of item IDs you want to craft together. Right now you're just passing in one metal per craft, so it's smelting the metal down because that's all it can do with one metal.

    How can i put them together?

                                console.log("NO REF");
    				for (let i = 0; i < scrap.length; i++) {
    					var array = [scrap.id, scrap.id, scrap.id]
    					tf2.craft(array);
    				}
    
  6. I have a question about where should i put my crafting recipe in the code

     

    My code

    //Show Online
    client.on('loggedOn', function (details) {
        console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID());
    	client.setPersona(1);
    });
    
    //crafting
    tf2.on("backpackLoaded", function(craft) {
    	manager.getInventoryContents(440, 2, true, function (err, inventory){
    		if (err) {
    			console.log(err);
    		} else {
    			var scrap = inventory.filter(function (item) {
    				return item.name == "Scrap Metal"
    			});
    			var reclaimed = inventory.filter(function (item) {
    				return item.name == "Reclaimed Metal"
    			});
    			var refined = inventory.filter(function (item) {
    				return item.name == "Refined Metal"
    			});
    			
    			if (refined.length < 1){
    				console.log("NO REF");
    				for (let i = 0; i < reclaimed.length; i++) {
    					tf2.craft([reclaimed[i].id]); //where should i put my recipe in?
    				}
    			}
    		}
    	});
    })
    
    https://dev.doctormckay.com/topic/1416-tf2-crafting-recipe/?hl=recipe
    

    I tried this code, yes it crafted me some metals, but i want refined metal while it gave me scrap from reclaimed metals. So how can i change my recipe in order to get what i needed?

     

    Btw Happy New Year McKay

  7. You need quotes around it. It's a string.

    Quote the whole thing like this give error

    Unknown SteamID input format "g:1:26823824"
    
    client.inviteToGroup(steamID, ["g:1:26823824"]);

    And Quote the id like this 

    client.inviteToGroup(steamID, [g:1:"26823824"]);
    

    doesnt work too

  8. You can use either the 64-bit one or the ID in the edit page, if you put the edit page ID into this formula: [g:1:id]

     

    For example [g:1:4] -> https://steamcommunity.com/gid/[g:1:4]

     

     

    Hmm I followed that but this error happens

     

                                                                           
    client.inviteToGroup(steamID, [g:1:26823824]);
    Unexpected token :
    
  9. ERROR

    "uri": "https://steamcommunity.com/inventory/" + userID.
    getSteamID64() + "/" + appID + "/" + contextID,
    
    ^
    
    TypeError: Cannot read property 'getSteamID64' of null
    

    My code

    function sendRec(steamID, amount){
    	if (!amount) {
            var amount = 1;
        }
    	if (amount == 0) {
    		console.log("User didn't provide a correct amount!");
    		return;
    	}
    	
    	manager.getUserInventoryContents(steamID, 440, 2, true, function (err, inventory){
    		if (err) {
    			console.log(err);
    		} else {
    			var scrap = inventory.filter(function (item) {
    				return item.name == "Scrap Metal"
    			});
    			
    			var refined = inventory.filter(function (item) {
    				return item.name == "Refined Metal"
    			});
    				
    			var NeededS = amount * 3
    			var NeededR = amount / 3
    			
    			if (scrap.length === 0 && refined.length === 0){
    				client.chatMessage(steamID, "It seems you don't have enough scrap.");
    				return;
    			} else if (amount > NeededS && amount > NeededR) {
    				client.chatMessage(steamID, "You don't have enough scrap. You'll need " + left + " more scrap metals.");
    				return;
    			} else if (amount <= NeededS || amount <= NeededR) {
    				manager.getInventoryContents(440, 2, true, function (err, inventory){
    					if (err) {
    						console.log(err);
    					} else {
    						var pool = inventory.filter(function (item) {
    								return item.name == "Reclaimed Metal"
    						});
    
    						// Let the user know we don't have any
    						if (pool.length === 0) {
    							client.chatMessage(steamID, "I don't have available.  Sorry!");
    							return;
    						} else if (amount > pool.length) {
    							console.log("User asked for more than my backpack.");
    							client.chatMessage(steamID, "I only have " + pool.length + " available.  Sorry!");
    							return;
    						} else if (amount <= pool.length) {
    							
    							// Start a new trade offer
    							var trade = manager.createOffer(steamID);
    							
    							// Add what we should to the current trade
    							console.log("Adding " + amount + " rec.");
    							
    							
    							if (scrap.length < NeededS) {
    								if (Number.isInteger(NeededR) == false){
    									return;
    								} else {
    									console.log("User doesn't have enough scrap. Sending REF OFFER!!");
    									//USER ITEMS
    									for (let i = 0; i < NeededR; i++) {
    										trade.addTheirItem(refined[i]);
    									}
    									//BOT ITEMS
    									for (let i = 0; i < amount; i++) {
    										trade.addMyItem(pool[i]);
    									}
    								}							
    							} else {
    								console.log("User have enough scrap. Sending SCRAP OFFER!!");
    								//USER ITEMS
    								for (let i = 0; i < NeededS; i++) {
    									trade.addTheirItem(scrap[i]);
    								}
    								//BOT ITEMS
    								for (let i = 0; i < amount; i++) {
    									trade.addMyItem(pool[i]);
    								}
    							}
    							
    							trade.setMessage("Here is your " + amount + " reclaimed metals");
    							trade.send(function(err, status) {
    								if (err) {
    									console.log(err);
    										return;
    								} else if (status == 'pending') {
    									console.log("Offer " + trade.id + "have been sent.");
    									community.startConfirmationChecker(15 * 1000, config.identity);
    									client.chatMessage(steamID, "Processing.");
    									client.chatMessage(steamID, "Offer Sent!! Check your trade offer by here https://steamcommunity.com/tradeoffer/" + trade.id + "/.");
    								} 
    							});				
    						}
    					}
    				});
    			}
    		}
    	})
    }
    
  10. What is the group steam id in the inviteToGroup

    https://github.com/DoctorMcKay/node-steam-user#invitetogroupusersteamid-groupsteamid
    

    There is two ID, the 64 ones and the id obtain by steam group edit page.

     

    What should i put in there??

     

    EDIT 1: Also is there a way to get the profile name of someone using steamID?
     

×
×
  • Create New...