выходит ошибка "TypeError: Cannot read properties of undefined (reading 'callbackService')" в чём проблема
код:
const mysql = require('mysql');
const { VK, MarketAttachment,Attachment, Keyboard } = require('vk-io');
const vk = new VK();
let user = new VK();
const keyboard = Keyboard;
const http = require('http');
const request = require("prequest");
const requests = require("request");
const requests = require("request");
const rq = require("prequest");
const fs = require("fs");;
const https = require('https');
const QuestionManager = require('vk-io-question');
const questionManager = new QuestionManager();
var randomstring = require("randomstring");
var Filter = require('bad-words'),
filter = new Filter();
const { snippets } = vk;
const plural = require('plural-ru');
user.setOptions({
token: 'vk1.a.HASY5TeU5JUXQ_xko3ApOvkUfuQ9RKuTrmwPLnWC__ztu8OGALvMKxDb-UAh0FtbUdPHxh1IBr5LxIELdDewQVNYTureuTAMaxMQgv1nBUclNthIcaTAQu5R0UmEiyQH7v-VXwyOl2bbjas89saK8BP9-Elvdqp19soLCJyL1BVcW4cu_ljr8nmgStvqMcRdcC7qtuVkgvyBwIIKbHTSQA'
});
var bot = {
accounts: {},
mysql: {
db: null,
connect: async function() {
bot.mysql.db = mysql.createPool({
host: 'localhost',
user: 'root',
password: '',
database: 'nodebotjs',
charset: 'utf8mb4_general_ci',
connectionLimit: 100
});
bot.mysql.db.getConnection(function(err, connection) {
if (err) { return console.error(`Ошибка с подключением к бд`, err); }
else { bot.mysql.load(); }
console.log(`База данных аккаунтов успешно подключена! `);
});
},
load: async function() {
bot.mysql.db.query('SELECT * FROM `accounts`', function(err, result) {
if (err) return console.log('[MYSQL] Ошибка при загрузке аккаунтов!', err);
if (!result || !result[0]) return;
var time = new Date();
for (var i = 0; i < result.length; i++) {
bot.accounts[result[i].vk] = result[i];
}
});
},
}
}
bot.mysql.connect();
var chat = {
users: {},
accounts: {},
mysql: {
db: null,
connect: async function() {
chat.mysql.db = mysql.createPool({
host: 'localhost',
user: 'root',
password: '',
database: 'nodebotjs',
charset: 'utf8mb4_general_ci',
connectionLimit: 100
});
chat.mysql.db.getConnection(function(err, connection) {
if (err) { return console.error(`Ошибка с подключением к бд`, err); }
else { chat.mysql.load(); }
console.log(`База данных чатов успешно подключена! `);
});
},
load: async function() {
chat.mysql.db.query('SELECT * FROM `users`', function(err, result) { //загрузка настроек чатов
if (err) return console.log('[MYSQL] Ошибка при загрузке чатов!', err);
if (!result || !result[0]) return;
var time = new Date();
for (var i = 0; i < result.length; i++) {
chat.users[result[i].user_id] = result[i];
}
});
},
}
}
chat.mysql.connect();
function getChatUser(user, chats){
return new Promise(function(resolve,reject){
chat.mysql.db.query('SELECT * FROM `users` WHERE `user_id` ="' + user +'" AND `chat_id` ="' + chats +'"', async function(err, chatik, fields){
if (err) console.log(err);
if (!empty(chatik)) {
const user_c = chatik[0];
resolve(user_c);
}else{
resolve();
}
});
});
}
vk.setOptions({
token: 'vk1.a.HASY5TeU5JUXQ_xko3ApOvkUfuQ9RKuTrmwPLnWC__ztu8OGALvMKxDb-UAh0FtbUdPHxh1IBr5LxIELdDewQVNYTureuTAMaxMQgv1nBUclNthIcaTAQu5R0UmEiyQH7v-VXwyOl2bbjas89saK8BP9-Elvdqp19soLCJyL1BVcW4cu_ljr8nmgStvqMcRdcC7qtuVkgvyBwIIKbHTSQA', //
apiMode: 'parallel_selected',
pollingGroupId: '224302388' //
});