Discord.Net icon indicating copy to clipboard operation
Discord.Net copied to clipboard

[Bug]: Editting an embed with an attachment duplicates the image outside of the embed message

Open defunky opened this issue 2 years ago • 2 comments

Check The Docs

  • [X] I double checked the docs and couldn't find any useful information.

Verify Issue Source

  • [X] I verified the issue was caused by Discord.Net.

Check your intents

  • [X] I double checked that I have the required intents.

Description

When an embed has image attached and you try to modify the embed, it will cause the image to be attached to regular message outside of the embed alongside the image within the embed itself. You can get around this by nullifying the attachment as part of the ModifyAsync however this will cause the image within the embed to become a deadlink after a period of time as discord will delete the image off its server.

Version

3.5.0

Working Version

No response

Logs

N/A

Sample

// Create the original message and attach an image to the embed
var embed = new EmbedBuilder()
                    .WithTitle("Test")
                    .WithDescription("Description")
                    .WithImageUrl($"attachment://{fileName}")
                    .WithColor(Color.LightGrey);
await Context.Channel.SendFileAsync(stream, fileName, embed: embed.Build())
// Modify the message by grabbing the embed and generate a embedbuilder
var message = Context.Interaction as SocketMessageComponent;
var embed = message.Message.Embeds.First().ToEmbedBuilder();

// Simply edit the description, you don't even need to modify ImageUrl
embed.WithDescription("New description");
await message.Message.ModifyAsync(x => 
    {
        // Uncommenting the line below will prevent the image being duplicated but will kill the link to image after couple of mins
        // x.Attachments = new Optional<IEnumerable<FileAttachment>(Enumerable.Empty<FileAttachment>());
        x.Embed = embed.Build()
    });


Packages

N/A

defunky avatar Apr 07 '22 21:04 defunky

Has there been any movement on this?

defunky avatar May 28 '22 13:05 defunky

Still occurs in 3.7.2

defunky avatar Jun 26 '22 17:06 defunky