Interface IInteractionPipeline
Pipeline behavior to surround the interaction handler. Implementations add additional behavior and await the next delegate.
Namespace: Color_Chan.Discord.Commands
Assembly: Color-Chan.Discord.Commands.dll
Syntax
public interface IInteractionPipeline
Examples
The following example showcases a simple implementation for a pipeline that measures the performance of the interactions.
public class PerformancePipeline : IInteractionPipeline
{
public async Task<Result<IDiscordInteractionResponse>> HandleAsync(IInteractionContext context, InteractionHandlerDelegate next)
{
var sw = new Stopwatch();
sw.Start();
var result = await next().ConfigureAwait(false);
sw.Stop();
Console.WriteLine($"Interaction ran for {sw.ElapsedMilliseconds.ToString()}ms.");
return result;
}
}
Methods
| Improve this Doc View SourceHandleAsync(IInteractionContext, InteractionHandlerDelegate)
A pipeline handler to surround the inner component interaction handler.
Declaration
Task<Result<IDiscordInteractionResponse>> HandleAsync(IInteractionContext context, InteractionHandlerDelegate next)
Parameters
Type | Name | Description |
---|---|---|
IInteractionContext | context | The current IInteractionContext of the component interaction request. |
InteractionHandlerDelegate | next | The delegate for the next action in the pipeline. This will execute the component interaction if all pipelines have been executed. |
Returns
Type | Description |
---|---|
Task<Result<IDiscordInteractionResponse>> | Result of IDiscordInteractionResponse containing the component interaction result. |