bwmarrin / discordgo

(Golang) Go bindings for Discord
BSD 3-Clause "New" or "Revised" License
5.12k stars 817 forks source link

Slash command attached images appearing outside of embeds #941

Open dcarriger opened 3 years ago

dcarriger commented 3 years ago

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?

CarsonHoffman commented 3 years ago

Your latest edit looks quite suspicious to me—I'd confirm what you actually have in your code. 🙂

dcarriger commented 3 years ago

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.

FedorLap2006 commented 3 years ago

Can you attach a screenshot of the result?