Update existing message
Closed this issue · 2 comments
bomb-on commented
Is it possible to edit/update the message sent with bot.sendMessage()
from the README example?
bot.on('message', function(user, userID, channelID, message, event) {
if (message === "ping") {
bot.sendMessage({
to: channelID,
message: "pong" // THIS IS THE MESSAGE I'D LIKE TO UPDATE SOMETIMES IN THE FUTURE
});
}
});
Peacerekam commented
use callback function to get message's ID
var m_id = '';
// ...
bot.sendMessage({
to: channelID,
message: "pong" // THIS IS THE MESSAGE I'D LIKE TO UPDATE SOMETIMES IN THE FUTURE
}, function (err, res){
// this is inside of callback function
// err => contains potential error
// res => contains message object (response)
// res.id => contains "pong" 's messageID
m_id = res.id
});
now you can use bot.editMessage sometime in the future (you might want to save channelID too tbh)
bot.editMessage({
channelID: channelID,
messageID: m_id,
message: "pongy pong"
})
bomb-on commented
Thanks a lot!!