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

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

Closed
3 tasks done
defunky opened this issue Apr 7, 2022 · 2 comments
Closed
3 tasks done
Assignees
Labels

Comments

@defunky
Copy link

defunky commented Apr 7, 2022

Check The Docs

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

Verify Issue Source

  • I verified the issue was caused by Discord.Net.

Check your intents

  • 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 defunky added the bug label Apr 7, 2022
@defunky
Copy link
Author

defunky commented May 28, 2022

Has there been any movement on this?

@quinchs quinchs self-assigned this May 28, 2022
@defunky
Copy link
Author

defunky commented Jun 26, 2022

Still occurs in 3.7.2

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

No branches or pull requests

2 participants