【问题标题】:How to make our bot read other bot embed message如何让我们的机器人阅读其他机器人嵌入消息
【发布时间】:2021-03-10 16:17:39
【问题描述】:

所以我正在尝试为一个名为“EPIC RPG”的机器人制作一个伴侣机器人,它是一个游戏机器人,并且我希望我的机器人对某个角色执行一些事件,以便人们注意到有一个事件正在发生,但是我就是不能让我的机器人读取嵌入,有什么想法吗?this is the EPIC RPG EVENT

【问题讨论】:

    标签: javascript discord.js


    【解决方案1】:

    您可以使用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.
    `);
    }
    }); 
    

    【讨论】:

    • 对不起,我不明白,那么我们如何用我的机器人自动回复它
    • 让嵌入 = message.embeds[0];如果(!嵌入)返回; console.log(embed.title); console.log(embed.description);
    • 把它放在client.on('message', message => ...) 的顶部并发送嵌入。控制台会嵌入标题和描述。
    • 仍然不明白,因为我只想让我的机器人阅读其他机器人嵌入的消息,然后我的机器人用角色提及和消息回复它。
    • 这就是如何阅读其他机器人的嵌入消息,这里是回复代码:message.reply(${message.guild.roles.cache.get('role_id')} message);
    猜你喜欢
    • 2020-12-06
    • 2019-12-23
    • 2019-04-11
    • 2019-05-10
    • 2020-12-31
    • 1970-01-01
    • 2017-11-02
    • 2021-09-19
    • 2019-11-23
    相关资源
    最近更新 更多