Answer the question
In order to leave comments, you need to log in
Event vk api not working?
There is a code, if the name of the conversation changes, then a check is performed: whether the user is an administrator or not. And it gives me an error: " Handle polling update error: TypeError: Cannot read properties of undefined (reading 'role') "
Code:
vk.updates.on(['chat_title_update'], (next, context) => {
const peer = chats.filter(x => x.id === next.chatId)[0];
const user = peer.members.filter(x => x.id === next.eventMemberId)[0];
if(user.role==0){
vk.api.messages.removeChatUser({ chat_id: next.chatId, user_id: user.id });
vk.api.messages.editChat({ chat_id: next.chatId, title: peer.name });
}
return context();
});
Answer the question
In order to leave comments, you need to log in
The problem was that this event does not send 'eventMemberId', it sends 'senderId'.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question