can't see at second getUserInventory

47 views Asked by At

The bot checks the user's gems and if there are enough gems, it transmits the swap offer. If the user cancels this trade offer and tries to create an offer again, then the bot says there are not enough gems. There's no problem creating the first trade offer, but if the first trade offer is canceled, the bot will always tell you there are not enough gems.

I could not solve this problem. Can you please help?

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;

0

There are 0 answers