CollectEventArgsAsync in Interactivity causes Null Ref on Dispose
Created by: jeffreyladd
Summary
This was originally reported on Discord by: Pando#7923
After the Global Timeout for Interactivity has been met when using Interactivity#CollectEventArgsAsync a Null Ref is hit within DSharpPlus.Interactivity.EventHandling.CollectRequest.cs within the Dispose Method at this._collected.Clear(); as _collected is already null
Details
Below is the code used to reproduce the Error
[Command("test")]
public async Task Test(CommandContext ctx)
{
var interactivity = ctx.Client.GetInteractivity();
var users = await interactivity.CollectEventArgsAsync<MessageCreateEventArgs>
(x => x.Message.Content == "join" && x.Channel == ctx.Channel, TimeSpan.FromSeconds(10))
.ConfigureAwait(false);
if (users == null)
{
await ctx.RespondAsync("error").ConfigureAwait(false);
}
else
{
await ctx.RespondAsync(users.Count.ToString()).ConfigureAwait(false);
}
}
var icfg = new InteractivityConfiguration()
{
Timeout = TimeSpan.FromMinutes(1)
};
_interactivity = _client.UseInteractivity(icfg);
Steps to reproduce
- Launch Bot
- execute !test command
- type join
- Everything finishes correctly
- After the 1 minute timeout is met from the Global configuration, a null reference is seen as _collected is already null