在discord.js中回复消息的嵌入

时间:2020-08-29 13:45:57

标签: javascript node.js discord discord.js bots

我已经用我的机器人发出了一个meme命令,这意味着在嵌入中发送图像。这是我当前的代码,它发送URL而不是图像。

var facts = [`filmdaily.co/wp-content/uploads/2020/06/2020-as-a-meme-lede-1300x1471.jpg`, `https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/bestmemes2020-1595859648.jpg?crop=1xw:1xh;center,top&resize=640:*`, `https://pics.me.me/me-makes-a-meme-with-3-recent-shocked-suprised-memes-combined-47596071.png`, `https://i.imgur.com/YXOP77u.jpg`, `https://i.pinimg.com/originals/52/69/1a/52691a89876e01886ed92bf7c6f66241.jpg`, `https://i2.wp.com/bestlifeonline.com/wp-content/uploads/2019/06/meltdown-explanation-meme.jpg?resize=1024%2C839&ssl=1`, `https://i.kym-cdn.com/photos/images/newsfeed/001/351/182/1e0.jpg`, `https://nexter.org/wp-content/uploads/2019/08/funniest-memes-2019-pics1.jpg`, `https://i.redd.it/ify275z7pgl31.jpg`, `https://i.pinimg.com/originals/38/81/5f/38815f4c1215691be9cfc06dc24b377d.png`, `https://images3.memedroid.com/images/UPLOADED203/5db23bdbe0be3.jpeg`, `https://64.media.tumblr.com/0e2154f93dc7091130449aabace56988/18749b33aab8b1e5-e4/s500x750/5f71186e116240aa71b6f6dbd43d3e8e08eca1ce.jpg`, `https://img.memecdn.com/memes-in-2019_c_7266070.jpg`, `https://pleated-jeans.com/wp-content/uploads/2019/09/auto-draft-201.jpg`, `https://i.redd.it/kq7pr7dn5c531.jpg`, `https://i.pinimg.com/736x/74/49/d3/7449d31a21c4496e0a2317791dccc8a5.jpg`, `https://i.redd.it/9dnls75fvzm41.jpg`, `https://images7.memedroid.com/images/UPLOADED699/5e9e804e4e752.jpeg`, `https://i.redd.it/nfgtc99g30b21.jpg`, `https://i.chzbgr.com/full/9371521792/h1A810A06/on-me-with-joe-oh-shit-who-told-you-wait-this-was-just-supposed-to-be-for-a-meme-whos-joe-joe-mama`, `https://i.redd.it/slllbiuqocj31.jpg`, `https://pbs.twimg.com/media/EWRq2emXQAM18gb.png`];
bot.on("message", message => {
    const fact = Math.floor(Math.random() * facts.length);
    const arguments = message.content.slice(prefix.length).trim().split(/ +/g);
    const commandName = arguments.shift().toLowerCase();
    if (message.content.startsWith(prefix) && commandName == "meme") {
        const embedjoke = {
            color: '#a13ddb',
            author: {
                name: 'PogBot',
                icon_url: 'https://i.imgur.com/g6rJoJj.png',
            },
            fields: [
                {
                    name: facts[fact],  
                    value: `Memes from Reddit, Google and Imgur`
                },
            ],
            footer: {
                text: 'PogBot Meme Command',
            },
        };
        message.channel.send({embed: embedjoke});
    }
})

1 个答案:

答案 0 :(得分:0)

您应将embed image属性用于URL。

image: {
        url: facts[fact]
    },

Example