K
K
kitmat2019-08-23 02:11:56
JavaScript
kitmat, 2019-08-23 02:11:56

How to implement sending messages to a specific conversation?

I can't implement sending messages from users to a separate conversation. Here is the script

cmd.hear(/^(?:репорт|report|rep|жалоба|вопрос)\s?([^]+)?/i, async (message, args, bot) => {
        if(message.chat) return message.send(`Обращаться в репорт можно только в ЛС ${config.group_url}`);
        if(!message.args[1]) return message.send(` » вы не написали жалобу | репорт [текст]`);
 
        for(i=0;i<25000;i++){
            if(users[i]){
            if(users[i].settings.adm >= 1){
                vk.api.call("messages.send", {
                    peer_id: users[i].id,
                    message: ` » [REPORT]\n » ID игрока: ${message.user.uid}\n » Жалоба: ${message.args[1]}\n » [Для ответа: ответ [ID] [TEXT]`
                }).then((res) => {}).catch((error) => {console.log('report error'); });
            }
        }
        }
        return message.send(` » Вы успешно отправили жалобу.`);
    });

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita, 2019-08-23
@kitmat

peer_id should be peer_id , not users.id . In the VK Api documentation, read the difference, for example, in the messages.send method

B
Bug, 2019-12-07
@thema__python3

peer_id should be equal to the id of the conversation where you want to send the message.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question