【发布时间】:2021-03-10 16:17:39
【问题描述】:
所以我正在尝试为一个名为“EPIC RPG”的机器人制作一个伴侣机器人,它是一个游戏机器人,并且我希望我的机器人对某个角色执行一些事件,以便人们注意到有一个事件正在发生,但是我就是不能让我的机器人读取嵌入,有什么想法吗?this is the EPIC RPG EVENT
【问题讨论】:
标签: javascript discord.js
所以我正在尝试为一个名为“EPIC RPG”的机器人制作一个伴侣机器人,它是一个游戏机器人,并且我希望我的机器人对某个角色执行一些事件,以便人们注意到有一个事件正在发生,但是我就是不能让我的机器人读取嵌入,有什么想法吗?this is the EPIC RPG EVENT
【问题讨论】:
标签: javascript discord.js
您可以使用Message.embeds。它返回消息中所有嵌入的数组。由于机器人每条消息只能发送 1 个嵌入,因此 message.embeds[0] 将返回嵌入的 MessageEmbed 对象。
所以你可以使用下面的代码:
let embed = message.embeds[0];
embed.title // the title of the embed
embed.description // the description of the embed
[编辑] 完整代码:
client.on('message', message => {
let embed = message.embeds[0];
if (message.author.id == 'epicrpgbot_id' && embed && embed.fields && embed.fields[0].title == 'IT'S RAINING COINS') {
// replace 'epicrpgbot_id with the bot's id
message.channel.send(`Embed
title: ${embed.title}
description: ${embed.description}
// replace this with the message you want to write
${client.users.cache.get('bot_id')} // replace 'bot_id' with the epic rpg bot's id.
`);
}
});
【讨论】:
client.on('message', message => ...) 的顶部并发送嵌入。控制台会嵌入标题和描述。
${message.guild.roles.cache.get('role_id')} message);