Display Attachment in Embed

The attachment option returns: https://media.discordapp.net/attachments/889518013429194782/1136474759866109952/image.png How would I get the image URL so I can use it to set it as the image in an embed?
7 Replies
d.js toolkit
d.js toolkit14mo 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!
factor
factor14mo ago
const options = interaction.data.options;
...
const attachment = options.find((option) => option.name === "attachment" && option.type === ApplicationCommandOptionType.Attachment);
...
const embed = new EmbedBuilder()
...
.setImage()
const options = interaction.data.options;
...
const attachment = options.find((option) => option.name === "attachment" && option.type === ApplicationCommandOptionType.Attachment);
...
const embed = new EmbedBuilder()
...
.setImage()
Squid
Squid14mo ago
Not sure why you get your option values like that You can just do interaction.options.getAttachment('attachment').url
factor
factor14mo ago
factor
factor14mo ago
I am using @djs/core /rest /ws
client.on(GatewayDispatchEvents.InteractionCreate, async ({ data: interaction, api }) => {
client.on(GatewayDispatchEvents.InteractionCreate, async ({ data: interaction, api }) => {
duck
duck14mo ago
further attachment data such as <APIAttachment>.url would be found in the resolved data <APIApplicationCommandInteraction>.data.resolved.attachments is keyed by id (the value of the option) if you're using /core, you'll want to reference and familiarize yourself with the discord api docs directly
factor
factor14mo ago
got it, thank you
Want results from more Discord servers?
Add your server