A
A
Andrey Daniluk2021-10-10 18:04:57
API
Andrey Daniluk, 2021-10-10 18:04:57

How to find the sender id in node-vk-bot-api?

Hi all. The other day I dug up this library and decided to write a bot while studying node js

https://github.com/node-vk-bot-api/node-vk-bot-api

Everything seems to be fine, but I don’t know how to find out the message sender ID for further actions with id.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sema-fedotov, 2021-10-16
@sema-fedotov

If your bot works on commands, then paste the following code and see the keys and their values. Perhaps there will be keys by type: senderId, user_id, etc.

bot.command('/start', async (ctx) => {
  console.log(ctx)
});

After you find the desired key, use it to get the id:
const user_id = ctx.senderId
Instead of senderId - the found key

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question