...
if (response.summ > check) {
io.emit('acceptoffer', {steamid: offer.steamid_other})
helper.msg('More Than Min - ' + offer.tradeofferid);
if(timer <= 28 && timer != 0) {
offers.declineOffer({tradeOfferId: offer.tradeofferid}, function() {
currentGameOffers.splice(currentGameOffers.indexOf(offer.tradeofferid), 1);
helper.msg('Timer less than 28 seconds - ' + offer.tradeofferid);
} else {
try {
offers.acceptOffer({tradeOfferId: offer.tradeofferid}, function(err, log) {
if (err) {
...
知道我在这里做错了吗?
我得到的错误是
} else {
^^^^
SyntaxError: Unexpected token else
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
我试图做的是,如果javascript上的计时器是&lt; = 28并且&lt;&gt;从0开始,然后执行offer.declineOffer,如果它没有运行offer.AcceptOffer。
我真的很抱歉,如果我没有在这里发帖,我也很抱歉我的英语。
答案 0 :(得分:0)
首先,在你的问题得到太多的挫折之前重新解释你的问题并被埋没,嗯,某事。需要适当的句子来理解问题的问题和意图,以便其他人可以帮助你。
您已将else
添加到function
的右大括号。
而是尝试:
...
})
} else {
...
HTH
答案 1 :(得分:0)
您从(
开放offers.declineOffer
,从{
块开放if
。您应该格式化代码以查看问题:
if (response.summ > check) {
io.emit('acceptoffer', {steamid: offer.steamid_other})
helper.msg('More Than Min - ' + offer.tradeofferid);
if (timer <= 28 && timer != 0) {
offers.declineOffer({tradeOfferId: offer.tradeofferid}, function () { // starts a function definition
currentGameOffers.splice(currentGameOffers.indexOf(offer.tradeofferid), 1);
helper.msg('Timer less than 28 seconds - ' + offer.tradeofferid);
} // closes the function definition
// OOPS! There's no } to close the if block.
// You also need to close the ( from offers.declineOffer
// Add the ) and } here, like this:
);
}
else
{
try {
offers.acceptOffer({tradeOfferId: offer.tradeofferid}, function (err, log) {
if (err) {