Answer the question
In order to leave comments, you need to log in
How to overcome Cannot read properties of undefined (reading 'group') error?
Error:
Manager Active
Hint: hit control+c anytime to enter REPL.
Handle polling update error: TypeError: Cannot read properties of undefined (reading 'group')
at /home/runner/LES/index.js:532:46
at next (/home/runner/LES/node_modules/middleware-io/lib /index.js:198:13)
at /home/runner/LES/node_modules/middleware-io/lib/index.js:198:39
at /home/runner/LES/node_modules/vk-io/lib/index. js:6665:86
at next (/home/runner/LES/node_modules/middleware-io/lib/index.js:198:13)
at /home/runner/LES/node_modules/middleware-io/lib/index.js :198:39
at /home/runner/LES/node_modules/vk-io/lib/index.js:6665:86
at next (/home/runner/LES/node_modules/middleware-io/lib/index.js:198:13)
at /home/runner/LES/node_modules/middleware-io/lib/index.js:198:39
/ home/runner/LES/index.js:494
chats[message.chatId].users[c.member_id].group == 3
^
TypeError: Cannot read properties of undefined (reading 'group')
at /home/runner/LES /index.js:494:43
at Array.map()
at /home/runner/LES/index.js:491:9
if(!chats[message.chatId]) {
chats[message.chatId] = {
activate: false,
motd: "",
name: 0,
flood: 0,
prefix: "/",
banlength: 0,
owner: 0,
owname: ``,
tex: false,
count: 0,
smilemsg: 0,
commsg: 0,
matmsg: 0,
symbols: 0,
forwarded_messages: 0,
photos: 0,
videos: 0,
audios: 0,
stikers: 0,
wall_posts: 0,
documents: 0,
audio_messages: 0,
dostup: {
warn: 1,
unwarn: 1,
ban: 3,
unban: 3,
permban: 4,
kick: 2,
prefix: 3,
event: 3,
setrules: 3,
helper: 4,
admin: 3,
moder: 3,
user: 3,
tex: 3,
detail: 2,
chatcfg: 3,
symbols: 3,
warns: 3,
tempban: 3,
motd: 3
},
bgold: false,
setting: {
symbols: 800,
warns: 3
},
settings: {
url: false,
invite: true,
kick_leave: false,
mute: false,
protectgroup1: false
},
rules: "Правила не установлены",
title: "none",
key: `${randomUid()}`,
banned: [],
lastname: {},
groups: {},
groups2: [],
invites: {},
names: [],
users: {}
}
}
chats[message.chatId].motd = "Добро пожаловать в беседу, чтобы узнать правила, напишите "+ chats[message.chatId].prefix +"rules";
vk.api.messages.getConversationMembers({ peer_id: message.peerId, fields: "id", group_id: 210644238 }).then(function(response){
let c = response;
c.items.map(function(c){
if(c.member_id < 1) return;
vk.api.call('users.get', {
user_ids: c.member_id,
fields: "photo_max,city,verified,status,domain,photo_id,sex,last_seen,first_name"
}).then(res => {
let user = res[0];
if(!chats[message.chatId].users[c.member_id]){
chats[message.chatId].users[c.member_id] = {
id: c.member_id,
name: `${user.first_name} ${user.last_name}`,
warns: 0,
active: 0,
uinvite: 0,
uchat: true,
chatdata: `${data()}`,
leave: false,
top: false,
stats: {
msg: 0,
smilemsg: 0,
commsg: 0,
matmsg: 0,
symbols: 0,
forwarded_messages: 0,
photos: 0,
videos: 0,
audios: 0,
stikers: 0,
wall_posts: 0,
documents: 0,
audio_messages: 0
},
tban: 0,
ban: false,
isBanned: false,
permanently: false,
group: 0
}
}
Строка 522:46 > if(chats[message.chatId].users[message.user].group == 0){
if(chats[message.chatId].settings.mute == true){
var smiles = message.text.match(/([\uD800-\uDBFF][\uDC00-\uDFFF])/g)
if(smiles != null) {
vk.api.messages.removeChatUser({ chat_id: message.chatId, member_id: message.user })
}
message.attachments.map(function(a) {
if (a.type == 'photo') {
vk.api.messages.removeChatUser({ chat_id: message.chatId, member_id: message.user })
} else if (a.type == 'sticker') {
vk.api.messages.removeChatUser({ chat_id: message.chatId, member_id: message.user })
} else if (a.type == 'video') {
vk.api.messages.removeChatUser({ chat_id: message.chatId, member_id: message.user })
} else if (a.type == 'audio') {
vk.api.messages.removeChatUser({ chat_id: message.chatId, member_id: message.user })
} else if (a.type == 'wall') {
vk.api.messages.removeChatUser({ chat_id: message.chatId, member_id: message.user })
} else if (a.type == 'doc') {
vk.api.messages.removeChatUser({ chat_id: message.chatId, member_id: message.user })
} else if (a.type == 'audio_message') {
vk.api.messages.removeChatUser({ chat_id: message.chatId, member_id: message.user })
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question