[Feature] Config Bypass for CanSendResponse (#2932)
* Adds bool switch for DeferAsyncTimeCheck in DiscordConfig * Adds DeferAsyncTimeCheck bool to DiscordSocketClient * Adds DeferAsyncTimeCheck to DeferAsync in SocketCommandBase * Adds DeferAsyncTimeCheck to DeferAsync in SocketModal * Adds DeferAsyncTimeCheck to DeferAsync in SocketMessageComponent * Changes name of DeferAsyncTimeCheck to be more general * Moves ResponseInternalTimeCheck from socket client to base client * Adds ResponseInternalTimeCheck to Rest interactions * Adds ResponseInternalTimeCheck to socket interactions
This commit is contained in:
@@ -87,7 +87,7 @@ namespace Discord.WebSocket
|
||||
if (!IsValidToken)
|
||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||
|
||||
embeds ??= Array.Empty<Embed>();
|
||||
@@ -154,7 +154,7 @@ namespace Discord.WebSocket
|
||||
if (!IsValidToken)
|
||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||
|
||||
embeds ??= Array.Empty<Embed>();
|
||||
@@ -218,7 +218,7 @@ namespace Discord.WebSocket
|
||||
if (!IsValidToken)
|
||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||
|
||||
if (args.AllowedMentions.IsSpecified)
|
||||
@@ -418,7 +418,7 @@ namespace Discord.WebSocket
|
||||
/// <inheritdoc/>
|
||||
public async Task DeferLoadingAsync(bool ephemeral = false, RequestOptions options = null)
|
||||
{
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||
|
||||
var response = new API.InteractionResponse
|
||||
@@ -442,7 +442,7 @@ namespace Discord.WebSocket
|
||||
/// <inheritdoc/>
|
||||
public override async Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
|
||||
{
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||
|
||||
var response = new API.InteractionResponse
|
||||
@@ -469,7 +469,7 @@ namespace Discord.WebSocket
|
||||
if (!IsValidToken)
|
||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||
|
||||
var response = new API.InteractionResponse
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Discord.WebSocket
|
||||
if (!IsValidToken)
|
||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||
|
||||
embeds ??= Array.Empty<Embed>();
|
||||
@@ -151,7 +151,7 @@ namespace Discord.WebSocket
|
||||
if (!IsValidToken)
|
||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||
|
||||
embeds ??= Array.Empty<Embed>();
|
||||
@@ -215,7 +215,7 @@ namespace Discord.WebSocket
|
||||
if (!IsValidToken)
|
||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||
|
||||
if (args.AllowedMentions.IsSpecified)
|
||||
@@ -420,7 +420,7 @@ namespace Discord.WebSocket
|
||||
/// </remarks>
|
||||
public override async Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
|
||||
{
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||
|
||||
var response = new API.InteractionResponse
|
||||
@@ -450,7 +450,7 @@ namespace Discord.WebSocket
|
||||
/// <inheritdoc/>
|
||||
public async Task DeferLoadingAsync(bool ephemeral = false, RequestOptions options = null)
|
||||
{
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||
|
||||
var response = new API.InteractionResponse
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Discord.WebSocket
|
||||
/// </returns>
|
||||
public async Task RespondAsync(IEnumerable<AutocompleteResult> result, RequestOptions options = null)
|
||||
{
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||
|
||||
lock (_lock)
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace Discord.WebSocket
|
||||
if (!IsValidToken)
|
||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||
|
||||
embeds ??= Array.Empty<Embed>();
|
||||
@@ -143,7 +143,7 @@ namespace Discord.WebSocket
|
||||
if (!IsValidToken)
|
||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||
|
||||
var response = new API.InteractionResponse
|
||||
@@ -188,7 +188,7 @@ namespace Discord.WebSocket
|
||||
if (!IsValidToken)
|
||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
||||
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||
|
||||
embeds ??= Array.Empty<Embed>();
|
||||
@@ -352,7 +352,7 @@ namespace Discord.WebSocket
|
||||
/// </returns>
|
||||
public override async Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
|
||||
{
|
||||
if (!InteractionHelper.CanSendResponse(this))
|
||||
if (!InteractionHelper.CanSendResponse(this) && Discord.ResponseInternalTimeCheck)
|
||||
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||
|
||||
var response = new API.InteractionResponse
|
||||
|
||||
Reference in New Issue
Block a user