public async Task ModifyMessageAsync( LocalInteractionMessageResponse response, IRestRequestOptions options = null, CancellationToken cancellationToken = default) { Guard.IsNotNull(response); response.Type = InteractionResponseType.MessageUpdate; var client = Interaction.GetRestClient(); await client.CreateInteractionResponseAsync(Interaction.Id, Interaction.Token, response, options, cancellationToken).ConfigureAwait(false); SetResponded(InteractionResponseType.MessageUpdate); }
public async Task PongAsync( IRestRequestOptions options = null, CancellationToken cancellationToken = default) { if (Interaction.Type != InteractionType.Ping) { Throw.InvalidOperationException("The interaction type must be a ping to pong it."); } ThrowIfResponded(); var client = Interaction.GetRestClient(); var response = new LocalInteractionMessageResponse(InteractionResponseType.Pong); await client.CreateInteractionResponseAsync(Interaction.Id, Interaction.Token, response, options, cancellationToken : cancellationToken).ConfigureAwait(false); SetResponded(InteractionResponseType.Pong); }
public async Task DeferAsync( bool deferViaMessageUpdate, bool isEphemeral = false, IRestRequestOptions options = null, CancellationToken cancellationToken = default) { ThrowIfResponded(); var client = Interaction.GetRestClient(); var responseType = deferViaMessageUpdate ? InteractionResponseType.DeferredMessageUpdate : InteractionResponseType.DeferredChannelMessage; var response = new LocalInteractionMessageResponse(responseType) .WithIsEphemeral(isEphemeral); await client.CreateInteractionResponseAsync(Interaction.Id, Interaction.Token, response, options, cancellationToken).ConfigureAwait(false); SetResponded(responseType); }
public async Task DeferAsync( bool isEphemeral = false, IRestRequestOptions options = null, CancellationToken cancellationToken = default) { if (Interaction is IComponentInteraction) { await DeferAsync(true, isEphemeral, options, cancellationToken).ConfigureAwait(false); return; } ThrowIfResponded(); var client = Interaction.GetRestClient(); var response = new LocalInteractionMessageResponse(InteractionResponseType.DeferredChannelMessage) .WithIsEphemeral(isEphemeral); await client.CreateInteractionResponseAsync(Interaction.Id, Interaction.Token, response, options, cancellationToken).ConfigureAwait(false); SetResponded(InteractionResponseType.DeferredChannelMessage); }