我有一个最喜欢的不和谐机器人游戏,叫做“ EPIC RPG”,有一个针对玩家的活动,所以我想制作一个可以宣布事件并提及特定角色并添加一些消息的机器人,我需要您的想法,>
这是我的代码
client.on('message', (message) => {
if (message.author.id === '555955826880413696') {
if (message.embeds) {
const embed = message.embeds[0]
if (embed.title === "**IT'S RAINING COINS**") {
return message.channel.send('the COIN RAIN event is started')
}
}
}
})
该代码是根据这张图片编写的,因为我想用 IT'S RAINING COINS 语句触发该命令,并回答“ coin rain event is starts” https://i.stack.imgur.com/H5mjN.png,问题是我的机器人无法阅读嵌入消息,有什么想法吗?
PS:启动时,它表明title
上的单词if (embed.title === "Theblablabla
未定义
答案 0 :(得分:0)
正如我在图片中看到的那样,嵌入的标题不仅是文本,而且还有表情符号:
您应该更改embed.title === "**IT'S RAINING COINS**"
到embed.title.includes("IT'S RAINING COINS")
最终结果:
client.on('message', (message) => {
if (message.author.id === '555955826880413696') {
if (message.embeds.length == 1) {
const embed = message.embeds[0]
if (embed.title.includes("IT'S RAINING COINS")) {
return message.channel.send('the COIN RAIN event is started')
}
}
}
})