question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Broken message in cache after ModifyAsync with added embed

See original GitHub issue

Summary

GetMessageAsync returns a message with no Content, if it was previously edited with ModifyAsync to add an embed. (it doesn’t reproduce if no embed added on edit)

Details

D#+ 3.2.3 (no custom sockets) (got couple of confirmations it also happens on 4.0 nightly) .Net Core 2.2

Steps to reproduce

First, add the following commands:

private ulong testMsgId = 0;

[Command("test1")]
public async Task Test1Async(CommandContext ctx)
{
    var  msg1 = await ctx.RespondAsync("test message");
    testMsgId = msg1.Id;

    msg1 = await ctx.Channel.GetMessageAsync(testMsgId);
    await ctx.RespondAsync($"A: {msg1.Author.Username} at {msg1.Timestamp}: \"{msg1.Content}\"");
}

[Command("test2")]
public async Task Test2Async(CommandContext ctx)
{
    if (testMsgId == 0) { return; }

    var msg1 = await ctx.Channel.GetMessageAsync(testMsgId);
    await ctx.RespondAsync($"A: {msg1.Author.Username} at {msg1.Timestamp}: \"{msg1.Content}\"");

    if (msg1.Content != null)
    {
        await msg1.ModifyAsync(
            msg1.Content,
            new DiscordEmbedBuilder { Description = "test", Timestamp = DateTimeOffset.Now }
            );
    }

    msg1 = await ctx.Channel.GetMessageAsync(testMsgId);
    await ctx.RespondAsync($"B: {msg1.Author.Username} at {msg1.Timestamp}: \"{msg1.Content}\"");
}

Then, run them in the following order:

!test1
!test2
!test2

Every command should output “test message” in place of {msg1.Content}. But after first run of .test2 has modified it, on the second run it is empty.

Notes

I hope to have a fix or workaround for 3.2.x, unless you releasing 4.0 like tomorrow.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Emzi0767commented, May 28, 2019

It’s a classic Apple goto fail; bug.

0reactions
Naamlooscommented, May 28, 2019

Fix coming up, will backport to 3.x as well

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - ModifyAsync Not Working
You are missing a .Build() after WithDescription . Usually when using the builder pattern you usually need to build the desired type.
Read more >
Is there a cached version of messages / embeds history? ...
My bot duplicates the message, deleting the old one, and adds a live countdown - which worked fine when I first set it...
Read more >
Changelog
#2644 Added ComponentBuilder component removal methods. ... by after id (529fe3d); #2622 Added default thread ratelimit in guild text channels (f9c8530) ...
Read more >
C# (CSharp) IGuildUser.ModifyAsync Examples
ModifyAsync - 34 examples found. These are the top rated real world C# (CSharp) examples of IGuildUser.ModifyAsync extracted from open source projects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found