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.

GetNextMessageAsync returns null Results

See original GitHub issue


After using the MessageExtension.GetNextMessageAsync method (with or without parameters) on a DiscordMessage object, accessing the returned Results property causes NullReferenceException.


The length of time it took for the NRE to occur from the point GetNextMessageAsync is called is equivalent to the time specified in the interactivity configuration timeout. The NRE occurs even if you haven’t sent anything into the respective channel.

Steps to reproduce

  1. Send a message into a channel,
  2. Use the GetNextMessageAsync method on the message object,
  3. Enter a random word,
  4. Try to access the Results property and it should be null.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

OoLunarcommented, Jul 15, 2022

Confirmed bug, not because of the NRE but because GetNextMessageAsync isn’t properly getting the next message causing the method to timeout (as seen in InteractivityResult<DiscordMessage>.TimedOut). Here’s a repro:

InteractivityResult<DiscordMessage> nextMessage = await context.Message.GetNextMessageAsync();
if (nextMessage.TimedOut)
    await context.RespondAsync("Timed out.");
    await context.RespondAsync($"Message by {nextMessage.Result.Author.Username}:\n{nextMessage.Result.Content}");

Unofficially assigning @DWaffles if they wish to take up the issue

zontreckcommented, Dec 6, 2022

It’s the timing out that is the issue, the code never gets executed. At least it didn’t when I was debugging it and trying to find the exact source. @OoLunar mentioned this in a above post too.

Dec 5, 2022 6:12:11 PM Velvet @.***>:

Doing some debugging, it seems everything is registered correctly. The MatchRequest is successfully registered to the ConcurrentHashSet _matchrequests property in the EventWaiter class, the predicate is filled with the correct variables and the timeout occurs as expected.

What isn’t expected is that EventWaiter.HandleEvent isn’t executed until the _matchrequests variable is empty (which is when the match request has timed out and is removed)

Looking at the code, I can’t see how this would happen?

— Reply to this email directly, view it on GitHub[], or unsubscribe[]. You are receiving this because you commented.[Tracking image][]

Read more comments on GitHub >

github_iconTop Results From Across the Web

Async response to onMessage returns null - javascript
I am trying to get an asyc response with the chrome messaging system but it always returns the literal value null .
Read more >
getSession always returns null on server #1466
Hey community! I'm trying to get the user's session on server side in order to render the correct page (login or dashboard) from...
Read more >
[Solved] Null return value from a async function
If I use function lsinfo() without async the code works fine but info['_myip'] return null. The async keyword does nothing in your context ......
Read more >
Returning null from Task-returning methods in C#
In this blog post, we'll understand this behavior and the difference between returning null from an async vs. non- async method in C#....
Read more >
Async return types (C#)
Returning a Task enables WaitAndApologizeAsync to be awaited. The Task type doesn't include a Result property because it has no return value ...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found