javascript - 有人可以帮我解决这个问题吗?
问题描述
所以我做了一个不和谐的机器人,可以读取其他机器人嵌入并回复它
这是我的代码:
client.on("message", (message) => {
let embed = message.embeds[0];
if (
message.author.id == "555955826880413696" &&
embed &&
embed.fields &&
embed.fields[0].value.includes(
"Type **CATCH** (once) to collect some coins! The reward depend on how much players join\n"
)
) {
message.channel
.send(
"<@&742328576237633546> " +
"<a:coins:744946097558126662> " +
"**CATCH** " +
"<a:coins:744946097558126662>"
)
.catch(console.error);
} else console.log(embed);
});
解决方案
embed.fields
将要求从if
语句更改为embed.fields[0]
错误正在触发,因为embed.fields
它是空的(尽管仍然定义)。
推荐阅读
- angular - 使用异步管道时缓存发出的值以便能够过滤掉未来的发出
- python - PyTorch Tensorboard 与文档中的描述不符
- apache-spark - Spark+Mesos Initial job 没有接受任何资源;检查您的集群 UI 以确保工作人员已注册并拥有足够的资源
- sql - SQL 查询以确定是否有任何与曲目无关的艺术家
- sql - SQL : 获取相关属性
- javascript - JQuery 表不会加载。,无法加载资源
- python - Python阻止PC进入睡眠/锁定的方法
- reactjs - React Ag 网格 expandAll 在企业中
- sql - 当列数未知时,如何在多个列上连接两个表(pyspark)
- r - 为什么 lapply 不转发其他参数?