javascript - Discord js检测其他机器人的消息
问题描述
我正在尝试检测来自另一个不和谐机器人的消息。例如,如果另一个不和谐机器人说出“验证码”这个词,我的不和谐机器人会检测到它并 ping 我。希望还有一种方法可以检测另一个机器人的嵌入,而不仅仅是消息。
解决方案
// create a message event
client.on('message', (message) => {
if (message.author.bot) {
// if the message is a bot
console.log(`${message.author.username} sent: '${message.content}'`); // you can fetch the message text through `message.content`
if (message.embeds[0])
// if the message includes an embed
console.log(
`${message.author.username} sent an embed with the title ${message.embeds[0].title}`
); // you can fetch the embed content through `message.embeds[0]`
}
});
推荐阅读
- javascript - 如何将输入复选框中的值传递给jquery中的URL参数
- r - 如何对 47 个 nlevel 进行分类?
- python - 根据 API 中的标签返回下一页结果
- typescript - 我需要通过数据表获取一个对象数组,在cypress中使用cucumber
- git - 有人可以帮我将代码推送到我的 github 存储库吗?
- firebase - 从 AsyncSnapshot 对 Firebase 数据进行排序
> 带有 Dart .sort() 函数 - python - Pytorch 张量 MNIST 图像绘图
- javascript - 在 ReactJS 中解构 props
- google-sheets - 范围中的数据验证下拉列表,而不是仅在不使用第二个计算表的情况下有条件地显示值
- javascript - 如何在 HTML 中使用 JS 动态设置值单选按钮