updates.use(async (context, next) => {
if (context.is("message") && context.isOutbox || context.is('message') && context.senderType == "group") return;
if (context.text) {
console.log(chalk.yellow(`@id${context.senderId} ${ context.isChat ? "#" + context.chatId : "" }, text: ${ context.text.slice(0, 360) }`));
}
if (!chats[context.chatId]) {
let months = new Date().getMonth()
let days = new Date().getDate()
let hour = new Date().getHours()
let minute = new Date().getMinutes()
let second = new Date().getSeconds()
chats[context.chatId] = {
reg: `${nols(days)}.${nols(months)}.${new Date().getFullYear()}, ${nols(hour)}:${nols(minute)}:${nols(second)}`,
ownerid: 0,
rules: 0,
maxwarns: 3,
jointext: 0,
botname: "бот",
users: {}
}
}
if (!chats[context.chatId].users[context.senderId]) {
const [user_info] = await vk.api.users.get({ user_id: context.senderId });
chats[context.chatId].users[context.senderId] = {
rank: 0,
warns: 0,
autokick: 0,
vkid: context.senderId,
banned: 0,
name: `${user_info.user_id}`,
muted: 0
}
}
Ошибка:
Handle polling update error: TypeError: Cannot read property 'user_id' of undefined