discordgo
discordgo copied to clipboard
Slash command attached images appearing outside of embeds
So previously, I was able to do something like this when sending messages:
ms := &discordgo.MessageSend{
Embed: &discordgo.MessageEmbed{
Color: 0x78141b,
Description: description,
Fields: fields,
Image: &discordgo.MessageEmbedImage{
URL: "attachment://" + fileName,
},
},
Files: []*discordgo.File{
{
Name: fileName,
Reader: file,
ContentType: "image/jpeg",
},
},
}
The attached image would be part of the embed message.
Now, as part of my refactor for slash commands, I am trying to do something like this:
_, err = s.FollowupMessageCreate(s.State.User.ID, i.Interaction, true, &discordgo.WebhookParams{
Embeds: []*discordgo.MessageEmbed{
{
Description: description,
Color: 0x78141b,
Image: &discordgo.MessageEmbedImage{
URL: "attachment://" + fileName,
},
},
},
Files: []*discordgo.File{
{
Name: fileName,
Reader: file,
ContentType: "image/jpeg",
},
}})
The attached image no longer displays within the embed. External URLs in the URL field still embed the image properly.
Am I doing something wrong, or is this a new problem since migrating from a singular embed to a slice of embeds?
Your latest edit looks quite suspicious to me—I'd confirm what you actually have in your code. 🙂
Hey @CarsonHoffman,
fileName
in the code is actually fmt.Sprintf("images/%s", imageFile)
, my edit was just to make it more readable and I didn't edit it everywhere. The filename is identical throughout.
Can you attach a screenshot of the result?