gpt4 book ai didi

javascript - 意外的标记 ;定义 bool 变量时

转载 作者:搜寻专家 更新时间:2023-11-01 00:27:18 24 4
gpt4 key购买 nike

我正在设置一个可以检查价格的 TF2 交易机器人。定义 bool 值是否以键定价时出现错误。

我尝试在 if 语句中用 data[baseName].prices[qualityId.toString()].Tradable[craftable[isCraftable.toString()][0].currency == "keys"替换 isKeys 但得到if 语句中右括号的错误。

var data = {

};
var currencies = {

};
requestify.get('https://backpack.tf/api/IGetPrices/v4?raw=1&since=0&key=5cf17c256780725011449df2')
.then(function(response) {

data = response.getBody().response.items;
console.log(data["Australium Tomislav"].prices["11"].Tradable.Craftable);
}
);
requestify.get('https://backpack.tf/api/IGetCurrencies/v1?key=5cf17c256780725011449df2')
.then(function(response) {

currencies = response.getBody().response.currencies;
}
);

function toRef(keys, high) {
if (high) {
if (currencies.keys.price.value_high != undefined){
return currencies.keys.price.value_high * keys
} else {
return currencies.keys.price.value * keys
}
} else {
return currencies.keys.price.value * keys
}
}
function getPrice(item, high) {
var name = item.market_name;
var quality = item.tags[0].name;
var baseName = name.replace(quality + " ", "");
var qualityId = itemQualities[quality];
var isCraftable = true;
var isKeys = data[baseName].prices[qualityId.toString()].Tradable[craftable[isCraftable.toString()][0].currency == "keys"; // Error here
for (i = 0;i < item.description.length;i++) {
if (item.description[i].value == '( Not Usable in Crafting )') {
isCraftable = false;
}
}

if (high) {
if (isKeys) {
return toRef(data[baseName].prices[qualityId.toString()].Tradable[isCraftable.toString()][0].value_high], true);
} else {
return data[baseName].prices[qualityId.toString()].Tradable[isCraftable.toString()][0].value_high];
}
} else {
if (isKeys) {
return toRef(data[baseName].prices[qualityId.toString()].Tradable[isCraftable.toString()][0].value], false);
} else {
return data[baseName].prices[qualityId.toString()].Tradable[isCraftable.toString()][0].value];
}
}

}

`

G:\BOT\bot.js:106 var isKeys = data[baseName].prices[qualityId.toString()].Tradable[craftable[isCraftable.toString()][0].currency == "keys"; ^

SyntaxError: Unexpected token ;

是我得到的错误

最佳答案

TL;DR:您在错误行中缺少 ]。您在下面的 if(high){...} 行中有额外的 ]

您在该行中缺少方括号 ]var isKeys = ... 正如其他答案所暗示的那样。现在,我们不知道数据结构,所以它可以是,

data[baseName]
.prices[qualityId.toString()]
.Tradable[craftable[isCraftable.toString()][0].currency*]*

data[baseName]
.prices[qualityId.toString()]
.Tradable[craftable[isCraftable.toString()][0]*]*.currency

还有,

你在行上有额外的方括号,

if (high) {
if (isKeys) {
/*--here>>*/return toRef(data[baseName].prices[qualityId.toString()].Tradable[isCraftable.toString()][0].value_high, true);
} else {
/*--here>>*/return data[baseName].prices[qualityId.toString()].Tradable[isCraftable.toString()][0].value_high;
}
} else {
if (isKeys) {
/*--here>>*/ return toRef(data[baseName].prices[qualityId.toString()].Tradable[isCraftable.toString()][0].value, false);
} else {
/*--here>>*/return data[baseName].prices[qualityId.toString()].Tradable[isCraftable.toString()][0].value;
}
}

同样,我们不知道确切的数据结构。

关于javascript - 意外的标记 ;定义 bool 变量时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56656273/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com