discordgo icon indicating copy to clipboard operation
discordgo copied to clipboard

Slash command attached images appearing outside of embeds

Open dcarriger opened this issue 3 years ago • 3 comments

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?

dcarriger avatar May 22 '21 03:05 dcarriger

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

CarsonHoffman avatar May 22 '21 03:05 CarsonHoffman

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.

dcarriger avatar May 22 '21 04:05 dcarriger

Can you attach a screenshot of the result?

FedorLap2006 avatar Jun 15 '21 22:06 FedorLap2006