Answer the question
In order to leave comments, you need to log in
How to use forward_message in vk bot?
There is a command (from below) it works if you write -friend @user, but I want to just be able to forward the message and write -friend and he sent a request to the one whom he sent
vk.updates.hear(/^(?:-добавить|-друг)\s?([^]+)?/i, async (message) => {
if(message.senderId !== 348543284) return message.send(`У вас недостаточно прав!`)
let id = await vk.snippets.resolveResource(message.$match[1]);
let tex = `Денис отправил/одобрил заявку!`
vk.api.friends.add({ user_id: id.id, text: tex })
return message.send(`Вы отправили/одобрили заявку`);
});
Answer the question
In order to leave comments, you need to log in
async function getUserId(message) {
if (message.hasReplyMessage) {
return message.replyMessage.senderId;
} else if (message.hasForwards) {
return message.forwards[0].senderId;
} else {
const res = await vk.snippets.resolveResource(message.$match[1]);
return res.id;
}
}
vk.updates.hear(/^(?:-добавить|-друг)\s?([^]+)?/i, async (message) => {
if(message.senderId !== 348543284) return message.send(`У вас недостаточно прав!`)
let userId = await getUserId(message);
let tex = `Денис отправил/одобрил заявку!`
vk.api.friends.add({ user_id: userId, text: tex })
return message.send(`Вы отправили/одобрили заявку`);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question