U nexpected end of input. What to do?

Unexpected end of input Bot vk.
const {VK, Keyboard} = require('vk-io');
const vk = new VK();
const {updates} = vk;
const fs = require("fs"); 
const acc = require("./base/acc.json");
const tokens = require("./base/tokens.json"); //Chat Manager

setInterval(function(){
 fs.writeFileSync("./base/acc.json", JSON.stringify(acc, null, "\t")) 
 fs.writeFileSync("./base/tokens.json", JSON.stringify(tokens, null, "\t")) 
}, 1500);

//////////////////////////////////////////////////////////////////////////////////////////////

vk.setOptions({
 token: tokens.token
 apiMode: 'parallel',
 pollingGroupId: tokens.id
}); 

vk.updates.use(async (message, next) => { 
 if (message.is("message") && message.isOutbox) {return;}

 // Pass info about the user in the message, for convenience
 message.user = message.senderId; message.text = message.payload.text; 
 if (!message.text) return;

 // Check if a user already exists in the database, if not create
new_acc(message.user);

 if(acc.users[message.user].ban == true) {return;} // Check for blocked account.

 try { await next(); } catch (err) { console.error(err) }
});


//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

vk.updates.hear(/^(?:help)/i, (message) => { 
 let user = acc.users[message.user];

 return message.send(`
 The help - function of the bot.
 bot - testing.
 kick [ID] - kick user from chat.
 addmoder [ID] - assign a user the moderator.
 removemoder [ID] - take away moderator from the user.
 warn [ID] - to give a warning.
 (After 3 warnings is a ban)
 unwarn [ID] - to remove all warnings.

 Online online conversations.
 Composition - all moderators/admins
 - - - - 
 [ID] Is a reference to the user Vkontakte.
 To write without brackets.
`);
});

vk.updates.hear(/^(?:bot)/i, (message) => { 
 return message.send(`🤖`);
});

vk.updates.hear(/^(?:kick)(\s?https\:\/\/vk\.com\/)?(id)?([0-9]+)?([^]+)?/i, (message) => { 
 let user = acc.users[message.user];
 if(user.admin_level < 1) return;

 if(message.$match[4]) { 
 var domain = message.$match[4].split(" "); 
 vk.api.call("utils.resolveScreenName", { 
 screen_name: message.$match[4] 
 }).then((res) => { 
new_acc(res.object_id);
 if(acc.users[Res. object_id].admin_level == 2) return message.reply('⚠ ➾ Failure'); 
 vk.api.call("messages.removeChatUser", {chat_id: message.chatId, user_id: res.object_id })
 .catch((error) => {return message.send(`Error.`);
 }); 
 return 
 }) 
}else{
 if(!message.$match[3]) return message.reply("⚠ ➾ ID is not specified or specified incorrectly."); 
new_acc(message.$match[3]);
 if(acc.users[message.$match[3]].admin_level == 2) return message.reply('⚠ ➾ Failure'); 
 vk.api.call("messages.removeChatUser", { chat_id: message.chatId, user_id: message.$match[3] }).
 catch((error) => {return message.send(`Error.`);}); 
 return 
 } 
});

vk.updates.hear(/^(?:addmoder)(\s?https\:\/\/vk\.com\/)?(id)?([0-9]+)?([^]+)?/i, (message) => { 
 let user = acc.users[message.user];
 if(user.admin_level < 2) return;

 if(message.$match[4]) { 
 var domain = message.$match[4].split(" "); 
 vk.api.call("utils.resolveScreenName", { 
 screen_name: message.$match[4] 
 }).then((res) => { 
new_acc(res.object_id);
 if(acc.users[Res. object_id].admin_level == 2) return;
 acc.users[Res. object_id].admin_level = 1;
 return message.send(`⚠ ➾ You have assigned vk.com/id${res.object_id} by the moderator.`);
 }) 
}else{
 if(!message.$match[3]) return message.reply("⚠ ➾ ID is not specified or specified incorrectly."); 
new_acc(message.$match[3]);
 if(acc.users[message.$match[3]].admin_level == 2) return;
 acc.users[message.$match[3]].admin_level = 1;
 return message.send(`⚠ ➾ You have assigned vk.com/id${message.$match[3]} by the moderator.`);
 } 
});

vk.updates.hear(/^(?:removemoder)(\s?https\:\/\/vk\.com\/)?(id)?([0-9]+)?([^]+)?/i, (message) => { 
 let user = acc.users[message.user];
 if(user.admin_level < 2) return;

 if(message.$match[4]) { 
 var domain = message.$match[4].split(" "); 
 vk.api.call("utils.resolveScreenName", { 
 screen_name: message.$match[4] 
 }).then((res) => { 
new_acc(res.object_id);
 if(acc.users[Res. object_id].admin_level == 2) return; 
 acc.users[Res. object_id].admin_level = 0;
 return message.send(`⚠ ➾ You have taken vk.com/id${res.object_id} post.`);
 }) 
}else{
 if(!message.$match[3]) return message.reply("⚠ ➾ ID is not specified or specified incorrectly."); 
new_acc(message.$match[3]);
 if(acc.users[message.$match[3]].admin_level == 2) return;
 acc.users[message.$match[3]].admin_level = 0;
 return message.send(`⚠ ➾ You have taken vk.com/id${message.$match[3]} post.`);
 } 
});

vk.updates.hear(/^(?:warn)(\s?https\:\/\/vk\.com\/)?(id)?([0-9]+)?([^]+)?/i, (message) => { 
 let user = acc.users[message.user];
 if(user.admin_level < 2) return;

 if(message.$match[4]) { 
 var domain = message.$match[4].split(" "); 
 vk.api.call("utils.resolveScreenName", { 
 screen_name: message.$match[4] 
 }).then((res) => { 
new_acc(res.object_id);
 if(acc.users[Res. object_id].admin_level == 2) return; 
 acc.users[Res. object_id].warn += 1;
 if(acc.users[Res. object_id].ban == true) return message.send(`⚠ ➾ the User is already blocked.`);
 if(acc.users[Res. object_id].warn >= 3){
 acc.users[Res. object_id].warn = 0;
 acc.users[Res. object_id].ban = true;
 vk.api.call("messages.removeChatUser", {chat_id: message.chatId, user_id: res.object_id })
 .catch((error) => {return message.send(`Error.`);
});
 return message.send(`⚠ ➾ User vk.com/id${res.object_id} is locked.`);
}else{
 return message.send(`⚠ ➾ You issued a warning vk.com/id${res.object_id}.\n⚠ ➾ After 3 warnings - issued the ban.`);
}

 }) 
}else{
 if(!message.$match[3]) return message.reply("⚠ ➾ ID is not specified or specified incorrectly."); 
new_acc(message.$match[3]);
 acc.users[message.$match[3]].warn += 1;
 if(acc.users[message.$match[3]].ban == true) return message.send(`⚠ ➾ the User is already blocked.`);

 if(acc.users[message.$match[3]].warn >= 3){
 acc.users[message.$match[3]].warn = 0;
 acc.users[message.$match[3]].ban = true;
 vk.api.call("messages.removeChatUser", {chat_id: message.chatId, user_id: message.$match[3] })
 .catch((error) => {return message.send(`Error.`);
});
 return message.send(`⚠ ➾ User vk.com/id${message.$match[3]} blocked.`);
}else{
 return message.send(`⚠ ➾ You issued a warning vk.com/id${message.$match[3]}.\n⚠ ➾ After 3 warnings - issued the ban.`);
}
 } 
});

vk.updates.hear(/^(?:unwarn)(\s?https\:\/\/vk\.com\/)?(id)?([0-9]+)?([^]+)?/i, (message) => { 
 let user = acc.users[message.user];
 if(user.admin_level < 2) return;

 if(message.$match[4]) { 
 var domain = message.$match[4].split(" "); 
 vk.api.call("utils.resolveScreenName", { 
 screen_name: message.$match[4] 
 }).then((res) => { 
new_acc(res.object_id);
 if(acc.users[Res. object_id].admin_level == 2) return; 
 acc.users[Res. object_id].warn = 0;
 return message.reply(`⚠ ➾ You have removed all Varnas have vk.com/id${res.object_id}`); 
 }) 
}else{
 if(!message.$match[3]) return message.reply("⚠ ➾ ID is not specified or specified incorrectly."); 
new_acc(message.$match[3]);
 acc.users[message.$match[3]].warn = 0;
 return message.reply(`⚠ ➾ You have removed all Varnas have vk.com/id${message.$match[3]}`);
 } 
});

vk.updates.hear(/^(?:composition)/i, (message) => { 
 let text = ";
 for(i in acc.users){
 if(acc.users[i].admin_level >= 1){
 text += `vk.com/id${i} - moderator/admin`
}
}
 return message.send(text);
});

vk.updates.hear(/^(?:online)/i, (message) => { 

 vk.api.call("messages.getConversationMembers", {
 peer_id: 2000000000 + message.chatId, 
 fields: "online"
}).then(function(res){
 let text = ";
 for(i in res.profiles){
 if(res.profiles[i].online == 1){
 text += ` [id${res.profiles[i].id}| ${Res. profiles[i].first_name} ${Res. profiles[i].last_name}]\n`
}
 } 
 text += '⚠ Attract your attention!'
 return message.send(text)
})

 function check(status){
 if(status == 1) return "online"
 if(status == 0) return "offline"
}
}); 

async function run() {
 await vk.updates.startPolling();
 console.log('Bot started'); 
}

run().catch(console.error);

vk.updates.hear(/^(?:!asset)/i, (message) => { 
function new_acc(id){
if(!acc.users[id]){
 acc.users[id] = {
 admin_level: 0,
 ban: false
 warn: 0
}
}
}


What is the error?
March 23rd 20 at 18:48
1 answer
March 23rd 20 at 18:50
You have a team not finished.

Find more questions by tags BotsChats