簡體   English   中英

如何從 sendMessage 獲取 discord.io 消息 ID?

[英]How do I get a discord.io message id from a sendMessage?

我已經為消息設置了一個事件偵聽器。 我想讓機器人使用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: "😜",
});

如果沒有,對機器人自己的消息添加反應的最佳方式是什么? 謝謝你的幫助!

您可以從sendMessage()回調的響應 object 中獲取消息 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: "😜"
  });
});

參考:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM