Skip to content

Cancellation Tokens #2235

@ecrocombe

Description

@ecrocombe

Description

I enjoy using D#+ because it manages rate limits for me.

However, once i ask it to do something, it could be a long time before i see the result come back to me.

Take the following as an example.

private async Task StartFiveMinuteTimer(CancellationToken cancellationToken)
{
  PeriodicTimer timer = new(TimeSpan.FromMinutes(5));
  do 
  {  
    using CancellationTokenSource fiveMinuteToken= new CancellationTokenSource(TimeSpan.FromMinutes(5));
    using CancellationTokenSource linkedToked = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, fiveMinuteToken.Token);
  
    // ommited some other stuff like DB queries and HTTP requests that utilize the above tokens
  
    await discordChannel.ModifyAsync(x =>
    {
        x.Name = name;
    });
  } while (await timer.WaitForNextTickAsync(cancellationToken));
}

Here, its possible that the PeriodicTimer does not tick every 5 minutes if renaming the discordChannel is waiting until it knows it will not hit a rate limit.

Would it be possible for us to somehow say "hey D#+, give up trying to rename that channel", possibly through the use of CancellationToken's or other means.

Specify the libraries you want this feature request to affect

DSharpPlus, the core library, DSharpPlus.Rest

Other considerations

If you believe your too small to make an impact on this world, try spending the night with a couple of mosquitos.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Effort

    None yet

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions