Add thumbnail embed from locally running api

As the title says, is there a way to add an image as embed thumbnail without having to deploy the api online? I'm new to writing rest api, and was wondering if it's possible to do this
7 Replies
d.js toolkit
d.js toolkit4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
treble/luna
treble/luna4mo ago
do you mean local files?
Kyusaor
KyusaorOP4mo ago
I know local files are not supported for embed thumbnail But I'm planning to deploy a website someday, and I'm starting to test stuff to learn how to use apis, and I came across this interrogation If I'm running a rest api locally with every image etc that the bot as well as the website would use, could I also store embed thumnails and use them from there?
treble/luna
treble/luna4mo ago
local files are supported though
d.js docs
d.js docs4mo ago
Files in embeds should be attached via the message option object and referenced in the embed:
const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);

channel.send({
embeds: [embed],
files: [attachment]
});
const attachment = new AttachmentBuilder('./image.png', { name: 'image1.png' });
const embed = new EmbedBuilder()
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);

channel.send({
embeds: [embed],
files: [attachment]
});
Amgelo
Amgelo4mo ago
basically the same but with setThumbnail instead though if you really want to make a website you only need a file server, which is much easier to setup since doesn't even require code but that's outside the scope of djs, you'd need to ask in #other-js-ts
Kyusaor
KyusaorOP4mo ago
Oh didn't see that, pretty cool they added a way to do it, thanks !
Want results from more Discord servers?
Add your server