Почему не видит переменную commands на 98 строке?
Почему то программа не видит переменную commands и выдаёт ошибку, на 98 строке не видит переменную commands
if commands.indexOf(message) != -1 {
^^^^^^^^
SyntaxError: Unexpected identifier 'commands' at wrapSafe (node:internal/modules/cjs/loader:1281:20) at Module._compile (node:internal/modules/cjs/loader:1321:27) at Module._extensions..js (node:internal/modules/cjs/loader:1416:10) at Module.load (node:internal/modules/cjs/loader:1208:32) at Module._load (node:internal/modules/cjs/loader:1024:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12) at node:internal/main/run_main_module:28:49
const SteamUser = require('steam-user');
const SteamTotp = require('steam-totp');
const SteamCommunity = require('steamcommunity');
const TradeOfferManager = require('steam-tradeoffer-manager');
const Prices = require('./prices.json');
const config = require('./config.json');
function acceptOffer(offer) {
offer.accept((err) => {
community.checkConfirmations();
console.log("We Accepted an offer");
if (err) console.log("There was an error accepting the offer.");
});
}
function declineOffer(offer) {
offer.decline((err) => {
console.log("We Declined an offer");
if (err) console.log("There was an error declining the offer.");
});
}
function processOffer(offer) {
if (offer.isGlitched() || offer.state === 11) {
console.log("Offer was glitched, declining.");
declineOffer(offer);
} else if (offer.partner.getSteamID64() === config.ownerID) {
acceptOffer(offer);
} else {
var ourItems = offer.itemsToGive;
var theirItems = offer.itemsToReceive;
var ourValue = 0;
var theirValue = 0;
for (var i in ourItems) {
var item = ourItems[i].market_name;
if(Prices[item]) {
ourValue += Prices[item].sell;
} else {
console.log("Invalid Value.");
ourValue += 99999;
}
}
for(var i in theirItems) {
var item= theirItems[i].market_name;
if(Prices[item]) {
theirValue += Prices[item].buy;
} else {
console.log("Their value was different.")
}
}
}
console.log("Our value: "+ourValue);
console.log("Their value: "+theirValue);
if (ourValue <= theirValue) {
acceptOffer(offer);
} else {
declineOffer(offer);
}
}
var commands = ["!help", "!prices", "!contact"]; //Список команд и ответов на них,
чтобы не делать много условий
var anwsers = ["!prices - view a list of my prices\n!buy [n] [item name] (example: !buy
1 Refined Metal)\n!contact - contact owner", "1 Strange Carbonado Botkiller Wrench Mk.I
- 4 ref\n1 Strange Carbonado Botkiller Knife MkI - 3 ref",
"https://steamcommunity.com/profiles/76561199091863367/"];
const client = new SteamUser();
const community = new SteamCommunity();
const manager = new TradeOfferManager ({
steam: client,
community: community,
language: 'en'
});
const logOnOptions = {
accountName: config.username,
password: config.password,
twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret)
};
client.logOn(logOnOptions);
client.on('loggedOn', () => {
console.log('succesfully logged on.');
client.setPersona(SteamUser.EPersonaState.Online);
client.gamesPlayed([440]);
});
client.on("friend", function(steamID, relationship) { //Добавление в друзья
if (relationship == Steam.EFriendRelationship.PendingInvitee) {
steam.addFriend(steamID);
client.on("friendMessage", function(steamID, message) {
client.chatMessage(steamID, "Hello! Type !help in chat to view avaliable
commands");
});
}
})
client.on("friendMessage", function(steamID, message) { //Ответ на команду
if commands.indexOf(message) != -1 {
client.chatMessage(steamID, anwsers[commands.indexOf(message)]);
}
else if (message.slice(0, 5) == "!buy") {
manager.on('newOffer', (offer) => {
processOffer(offer);
});
}
else {
client.chatMessage(steamID, "Wrong command");
}
});
client.on('webSession', (sessionid, cookies) => {
manager.setCookies(cookies);
community.setCookies(cookies);
community.startConfirmationChecker(20000, config.identitySecret);
});
client.setOption("promptSteamGuardCode", false);