我已经为消息设置了事件监听器。我想让漫游器使用bot.addReaction()
对自己的消息做出反应。有没有办法在调用后保留messageId
?像这样:
const message = bot.sendMessage({
to: channelID,
message: `Oops... Sorry ${user}, that's not something I can understand.
After all, I'm just a computer!`,
});
bot.addReaction({
channelID: channelID,
messageID: message.d.id,
reaction: "?",
});
如果没有,对机器人自己的消息做出反应的最佳方法是什么?感谢您的帮助!
答案 0 :(得分:1)
您可以从sendMessage()
回调的响应对象中获取消息ID:
const message = bot.sendMessage({
to: channelID,
message: `Oops... Sorry ${user}, that's not something I can understand.
After all, I'm just a computer!`
}, (err, res) => {
bot.addReaction({
channelID,
messageID: res.id,
reaction: "?"
});
});
参考: