【问题标题】:How do I get a discord.io message id from a sendMessage?如何从 sendMessage 获取 discord.io 消息 ID?
【发布时间】:2020-11-01 20:50:36
【问题描述】:

我已经为消息设置了一个事件监听器。我想让机器人使用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: "????",
});

如果没有,对机器人自己的消息添加反应的最佳方式是什么?感谢您的帮助!

【问题讨论】:

  • Discord.io 已经 3 岁了。我建议改用 discord.js。它更先进,更易于使用。
  • 我已经换了。我可以说它已经更好了。这些文档更有启发性,而且很直观。

标签: javascript node.js discord discord.io


【解决方案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: "?"
  });
});

参考资料:

【讨论】:

  • 感谢@DaemonBeast。我是创建机器人的新手,你帮了很多忙。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-09-05
  • 2021-12-13
  • 2022-01-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-07-22
相关资源
最近更新 更多