如何使我的不和谐机器人阅读其他机器人嵌入的消息 [英] How to make my discord bot to read other bot embed messages
问题描述
我有最喜欢的不和谐机器人游戏,名为"EPIC RPG",有一个供玩家使用的活动,所以我想制作一个机器人,该机器人可以宣布活动并提及特定角色并添加一些消息,我需要您的想法,
I have favorite discord bot game called "EPIC RPG" there's an event for players, so I wanted to make a bot that can announce the event with mention a specific role and adding some messages, i need your ideas pls,
这是我的代码
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 语句触发该命令,并回答硬币雨事件开始". https://i.stack.imgur.com/H5mjN.png ,问题出在是我的机器人无法阅读嵌入消息,有什么主意吗?
that code is according to this picture, cuz I wanna trigger the command with the IT'S RAINING COINS statement and reply with "the coin rain event is started" https://i.stack.imgur.com/H5mjN.png, the problem is my bot cant read the embed messages, any ideas?
PS:启动时,它表明if (embed.title === "Theblablabla
上的单词title
未定义
PS : when I started it, it shows that word title
on if (embed.title === "Theblablabla
is undefined
推荐答案
正如我在图片中看到的那样,嵌入的标题不仅是文本,而且还有表情符号:
As I can see in the picture, the title of the embed isn't just a text but there is also an emoji:
您应该更改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')
}
}
}
})
这篇关于如何使我的不和谐机器人阅读其他机器人嵌入的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!