Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Files with InteractionRespond will not delete old or existing files #1524

Open
Janvos2506 opened this issue Apr 22, 2024 · 0 comments

Comments

@Janvos2506
Copy link

Hi,

I am trying to update the image in an embed. The behaviour I'm seeing is not what I was expecting, please see MVP down below.

When executing the component via the button click it calls InteractionRespond with InteractionResponseUpdateMessage. In this update I assign a new Files array with a new image. I also update the included Embed. I expected this to delete the previous image and load the new one. But what actually happens is it updates the embed but leaves the attached image hanging, please see the screenshot.

//Triggered by /PlayGame

err = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
	Type: discordgo.InteractionResponseChannelMessageWithSource,
	Data: &discordgo.InteractionResponseData{
		Embeds:     []*discordgo.MessageEmbed{&discordgo.MessageEmbed{
				Title:       "Map",
				Description: "map"
				Color:       0x00ff00,
				Image: &discordgo.MessageEmbedImage{
					URL:    "attachment://Map.png",
					Width:  512,
					Height: 512,
				},
			}
		},
		Flags:      discordgo.MessageFlagsEphemeral,
		Files: []*discordgo.File {
			{Name: "Map.png", ContentType: "image/png", Reader: r},
		 },
	},
})

//Triggerd by the button click via component
r := //Get bytes of image...
err = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse {
    Type: discordgo.InteractionResponseChannelMessageWithSource,
	Data: &discordgo.InteractionResponseData{
		Embeds:     []*discordgo.MessageEmbed{&discordgo.MessageEmbed{
				Title:       "Other Map",
				Description: "different map"
				Color:       0x00ff00,
				Image: &discordgo.MessageEmbedImage{
					URL:    "attachment://differentMap.png",
					Width:  512,
					Height: 512,
				},
			}
		},
		Flags:      discordgo.MessageFlagsEphemeral,
		Files: []*discordgo.File {
			{Name: "differentMap.png", ContentType: "image/png", Reader: r},
		 },
	},
})

This looks good
Screenshot 2024-04-22 223022

Here the old map stays put and is being rendered outside of its embed?
Screenshot 2024-04-22 223036

What is going on here? Am I handling this scenario correctly or is there a better way?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant