I wanna make a telegram bot game where bot send a message to group then other members can make reactions on this message. Then I enlist those members data and start the game for those members only.
How can I achive this functionality?
I tried
bot.on('message', async (msg) => {
const updates = await bot.getUpdates()
updates.forEach(async (update) => {
console.log(update)
})
})
But using this code I didn't avail to get reaction updates for messages.
1 Answer 1
At first, it is important to explicitly mention the "message_reaction" update type in the allowed_updates for the bot.
const bot = new TelegramBot(token, {
polling: {
params: {
allowed_updates: ["message", "message_reaction"],
}
}
});
Now you can listen to changes in message reaction as follows:
bot.on("message_reaction", (reaction) => {
// `reaction` is of type MessageReactionUpdated (https://core.telegram.org/bots/api#messagereactionupdated)
// `reaction.user` will be the user who changed the reaction
// `reaction.chat` will be the chat on which the message to which the reaction is updated exist
});
Make sure to check the official documentation for detailed info on different properties available and customize your bot.
2 Comments
Explore related questions
See similar questions with these tags.