Jump to content
McKay Development
Kappa

Error: cannot send an empty trade offer.

Recommended Posts

Hey there, I'm such a newbie in steambot coding. The main objective of the code would be that the bot should request a cs:go / tf2 key from a user who sends the command "!order" via trade offers. My current state is that the bot creates the offer but there's always an error because I get the error: "Cannot send an empty trade offer."

Is there anything which I'm too blind to see?

Thanks in advance!

My code:

 

function checkKeys(steamID) {
	var theirKeys = [];
	var amountOfKeysToAdd = 1;
	manager.getUserInventoryContents(steamID, config.keysFromCSGO && config.keysFromTF2, 2, true, function(err, inventory) {
		if (err) {
			console.log('Error getting user inventory.'.red);
		} else {
			console.log('Checking if user has CS:GO or TF2 keys.'.green);
			for (var n = 0; n < inventory.length; n++) {
				if(theirKeys.length < amountOfKeysToAdd && config.acceptedKeys.indexOf(inventory[n].market_hash_name) >= 0) {
					theirKeys.push(inventory[n]);
					console.log(inventory[n].market_hash_name);
				}
			}
			console.log('User has' + theirKeys.length + 'key(s).');
		}
	});
}

function sendOffer(sender) {
let theirKeys = [];
var offer = (manager.createOffer(sender.getSteamID64()));
	offer.addTheirItems(theirKeys);
	offer.send ((err, status) => {
		if (err) {
			console.log('There was an error sending the offer.'.red + err);
		} else {
			console.log('An offer has been sent.'.green);
			console.log(status);
		}
	});
}

client.on('friendMessage', (sender, message) => {
	if (message === "!start") {
		client.chatMessage(sender, config.startMessage);
	} else if (message === "!owner") {
		client.chatMessage(sender, config.ownerMessage);
	} else if (message === "!help") {
		client.chatMessage(sender, config.helpMessage);
	} else if (message === "!order") {
		client.chatMessage(sender, config.orderMessage);
		client.chatMessage(sender, 'Processing your request....');
		checkKeys(sender);
			console.log('Creating offer...'.cyan);
			sendOffer(sender);
	} else if (message === "!proof") {
		client.chatMessage(sender, config.proofMessage);
	}
});

 

Share this post


Link to post
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...