机器人检查用户的宝石,如果有足够的宝石,它会发送交换报价。如果用户取消此交易报价并尝试再次创建报价,那么机器人会说没有足够的宝石。创建第一个交易报价没有问题,但如果第一个交易报价被取消,机器人总是会告诉你没有足够的宝石。
我无法解决这个问题。你能帮忙吗?
case "gems":
community.getUserInventory(partner, 753, 6, true, (error, items) => {
if(error) {
users.removeReservation(partner, true, removeFunc);
return callback(error);
}
let count = 0;
for(let i = 0; i < items.length; i++) {
let item = items[i];
if(item.type.toLowerCase() != "steam gems")
continue;
count += item.amount;
if(count > price) {
item.amount -= (count - price);
count -= (count - price);
}
offer.addTheirItem(item);
if(count == price)
break;
}
if(count < price) {
users.removeReservation(partner, true, removeFunc);
return callback("/quote You do not have enough gems to purchase unique games.");
}
if(count > 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;