Jump to content
McKay Development

offer.addMyItems Error Context


ahmet

Recommended Posts

checks the user's gems and sends a trade offer. but I want the bot to add 1 gems to the trade offer created, but it always gives an error.

I'm trying to do this with the following code trying to add 1 ore from the bot's inventory

offer.addMyItems(item.amount = 1);

I want the bot to add 1 gems to the trade offer. How can I do that?

My Codes; 
 

case "gems":

community.getUserInventory(partner, 753, 6, true, (error, items) => {
	if(error) {
		users.removeReservation(partner, true, removeFunc);
		return callback(error);
	}

	let accepted = files.getConfig().steamGems;
	var botgems = 0;
	var need = price;

	for (var i = 0; i < items.length; i += 1) {
		var item = items[i];
		if (need !== 0) {
			if (accepted.indexOf(item.market_hash_name) >= 0) {

				item.amount = need <= item.amount ? need : item.amount;
				need -= item.amount;
				botgems += item.amount;

			}
		}

		offer.addTheirItem(item);
		offer.addMyItems(item.amount = 1);

		if(botgems == price)
			break;
	}

	if(botgems < price) {
		users.removeReservation(partner, true, removeFunc);

		
			return callback("/quote You do not have enough gems to purchase unique games.");

	}


	if(botgems > price) {
		users.removeReservation(partner, true, removeFunc);

		
			return callback("/quote  An error occurred, please try again later.");
		
	}

	offer.send((error, status) => {
		if(error) {
			users.removeReservation(partner, true, removeFunc);
			return callback(error);
		}

		if(status == "pending") {
			community.acceptConfirmationForObject(files.getConfig().identity, offer.id, error => {
				if(error) {
					users.removeReservation(partner, true, removeFunc);
					return callback(error);
				}

				callback(null, "https://steamcommunity.com/tradeoffer/" + offer.id);
			});
		} else if(status == "sent")
		callback(null, "https://steamcommunity.com/tradeoffer/" + offer.id);
	});
});

break;

 

Link to comment
Share on other sites

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...