来自 Discord.js Bot 的嵌入式 URL 图片未出现
Image not appearing from embedded URL from Discord.js Bot
我现在遇到的问题是我嵌入的 URL 中的图像没有显示出来。现在通常对于 Discord,当您发送图像 link 时,它看起来像这样:
What usually happens when you send an image link
现在,我尝试嵌入图像 links。这嵌入图像 URL 很好,但是,现在图像没有在图像 URL 下方弹出,但嵌入有效:The embedded image URL
这是我当前的代码:
} else if(message.content == '/memes' || message.content =='/meme') {
message.channel.sendMessage({embed: {
color: 3447003,
description: memes[Math.floor(Math.random()*75)]
}});
//message.reply(memes[Math.floor(Math.random()*75)])
}
您的图片 URL 似乎来自 memes[Math.floor(Math.random()*75)]
,对吗?
您还需要在嵌入的 image
属性上设置 URL。像这样:
const imageURL = memes[Math.floor(Math.random()*75)];
message.channel.sendMessage({embed: {
color: 3447003,
description: imageURL,
image: {url: imageURL}
}});
此外,您使用的是标准 Discord.js 库吗?如果是这样,我建议不要再使用 .sendMessage
因为它已被弃用。否则,请注意您使用的是哪个库。
我现在遇到的问题是我嵌入的 URL 中的图像没有显示出来。现在通常对于 Discord,当您发送图像 link 时,它看起来像这样: What usually happens when you send an image link
现在,我尝试嵌入图像 links。这嵌入图像 URL 很好,但是,现在图像没有在图像 URL 下方弹出,但嵌入有效:The embedded image URL
这是我当前的代码:
} else if(message.content == '/memes' || message.content =='/meme') {
message.channel.sendMessage({embed: {
color: 3447003,
description: memes[Math.floor(Math.random()*75)]
}});
//message.reply(memes[Math.floor(Math.random()*75)])
}
您的图片 URL 似乎来自 memes[Math.floor(Math.random()*75)]
,对吗?
您还需要在嵌入的 image
属性上设置 URL。像这样:
const imageURL = memes[Math.floor(Math.random()*75)];
message.channel.sendMessage({embed: {
color: 3447003,
description: imageURL,
image: {url: imageURL}
}});
此外,您使用的是标准 Discord.js 库吗?如果是这样,我建议不要再使用 .sendMessage
因为它已被弃用。否则,请注意您使用的是哪个库。