Steam Tf2交易BOT Node.js问题

Steam Tf2交易BOT Node.js问题,node.js,steam,Node.js,Steam,这是我的一段代码 // Any time an item changes in the trade window trade.on('offerChanged', function(itemAdded, item) { if (itemAdded) { logger.info('User added: '+item.name) if (item.name == 'Festive Black Box') { trade.chatMsg('Cool!');

这是我的一段代码

// Any time an item changes in the trade window
trade.on('offerChanged', function(itemAdded, item) {
if (itemAdded) {
    logger.info('User added: '+item.name)
    if (item.name == 'Festive Black Box') {
        trade.chatMsg('Cool!');
        trade.addItem('Scrap Metal');
    }
}
所以,基本上我哥哥把这个东西放进(节日黑匣子),它应该放一块废料,但它没有,而是说“酷!”(所以我知道它有效)而且机器人没有插入废料,我等了很长时间,似乎不起作用,而且我的库存中只有一块废金属

下面是我的一些代码

// After we accept the trade, we deal with the trade session
client.on('sessionStart', function(steamID) {
    inTrade = true;
    client.setPersonaState(steam.EPersonaState.Busy);
    trade.open(steamID, function() { // Pass the trade off to our steam-trade library
    trade.loadInventory(appid.TF2, contextid.TF2, function(inv) {
        inventory = inv;
        scrap = inv.filter(function(item) { return item.name == 'Scrap Metal';});
        logger.error(scrap)
            if (!inv) {
                logger.error('Error getting own inventory.  Cancelling trade.');
                client.sendMessage(steamID, 'Could not load my inventory, please contact my creator.');
                trade.cancel(steamID);
            } else {
                logger.debug('Found '+inv.length+' items in my inventory.');
                myBackpack = inv; // Now we can access it globally
                // If you want to put items up in the trade window immediately,
                // here is where you could do it. Instead we're calling a custom function.
                onTradeStart(steamID); // Our custom function
            }
        });
    });
});
我们开始:

// Any time an item changes in the trade window
trade.on('offerChanged', function(itemAdded, item) {
    if (itemAdded) {
        logger.info('User added: '+item.name)
        if (item.name == 'Festive Black Box') {
            trade.chatMsg('Cool!');
            trade.addItem('Scrap Metal');
            logger.info(trade.addItems(scrap));
        }
    }
    //if (itemAdded)
    //    logger.info('User added: '+item.name);
    //else
    //    logger.info('User removed: '+item.name);
});
试用

scrap = inv.filter(function(item) { 
     return item.tags.some(function(element, index, array) {
            return element.internal_name == 'Scrap Metal';
     });
});

您是否记录了
项。name
?不,我不知道它到底是什么,可能是“废金属”项。name?@TomA示例?我已尝试修复此项2.5小时。。。没有lucklogger.info(item.name)-是吗?谢谢,虽然已经很晚了,但我很快就会回到bots