[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:
@@ -205,6 +205,14 @@ namespace Discord
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public bool UseInteractionSnowflakeDate { get; set; } = true;
|
public bool UseInteractionSnowflakeDate { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets whether or not any responses to Discord will make an internal expiration check.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This should generally be set to <see langword="false"/> in a development environment due to potential latency issues.
|
||||||
|
/// </remarks>
|
||||||
|
public bool ResponseInternalTimeCheck { get; set; } = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets if the Rest/Socket user <see cref="object.ToString"/> override formats the string in respect to bidirectional unicode.
|
/// Gets or sets if the Rest/Socket user <see cref="object.ToString"/> override formats the string in respect to bidirectional unicode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace Discord.Rest
|
|||||||
public TokenType TokenType => ApiClient.AuthTokenType;
|
public TokenType TokenType => ApiClient.AuthTokenType;
|
||||||
internal bool UseInteractionSnowflakeDate { get; private set; }
|
internal bool UseInteractionSnowflakeDate { get; private set; }
|
||||||
internal bool FormatUsersInBidirectionalUnicode { get; private set; }
|
internal bool FormatUsersInBidirectionalUnicode { get; private set; }
|
||||||
|
internal bool ResponseInternalTimeCheck { get; private set; }
|
||||||
|
|
||||||
/// <summary> Creates a new REST-only Discord client. </summary>
|
/// <summary> Creates a new REST-only Discord client. </summary>
|
||||||
internal BaseDiscordClient(DiscordRestConfig config, API.DiscordRestApiClient client)
|
internal BaseDiscordClient(DiscordRestConfig config, API.DiscordRestApiClient client)
|
||||||
@@ -59,6 +60,7 @@ namespace Discord.Rest
|
|||||||
|
|
||||||
UseInteractionSnowflakeDate = config.UseInteractionSnowflakeDate;
|
UseInteractionSnowflakeDate = config.UseInteractionSnowflakeDate;
|
||||||
FormatUsersInBidirectionalUnicode = config.FormatUsersInBidirectionalUnicode;
|
FormatUsersInBidirectionalUnicode = config.FormatUsersInBidirectionalUnicode;
|
||||||
|
ResponseInternalTimeCheck = config.ResponseInternalTimeCheck;
|
||||||
|
|
||||||
ApiClient.RequestQueue.RateLimitTriggered += async (id, info, endpoint) =>
|
ApiClient.RequestQueue.RateLimitTriggered += async (id, info, endpoint) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace Discord.Rest
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= Array.Empty<Embed>();
|
embeds ??= Array.Empty<Embed>();
|
||||||
@@ -317,7 +317,7 @@ namespace Discord.Rest
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public override string Defer(bool ephemeral = false, RequestOptions options = null)
|
public override string Defer(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!");
|
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
@@ -352,7 +352,7 @@ namespace Discord.Rest
|
|||||||
/// <exception cref="InvalidOperationException"></exception>
|
/// <exception cref="InvalidOperationException"></exception>
|
||||||
public override string RespondWithModal(Modal modal, RequestOptions options = null)
|
public override string RespondWithModal(Modal modal, 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");
|
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace Discord.Rest
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= Array.Empty<Embed>();
|
embeds ??= Array.Empty<Embed>();
|
||||||
@@ -153,7 +153,7 @@ namespace Discord.Rest
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
if (args.AllowedMentions.IsSpecified)
|
if (args.AllowedMentions.IsSpecified)
|
||||||
@@ -424,7 +424,7 @@ namespace Discord.Rest
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public string DeferLoading(bool ephemeral = false, RequestOptions options = null)
|
public string DeferLoading(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");
|
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
@@ -458,7 +458,7 @@ namespace Discord.Rest
|
|||||||
/// <exception cref="InvalidOperationException"></exception>
|
/// <exception cref="InvalidOperationException"></exception>
|
||||||
public override string Defer(bool ephemeral = false, RequestOptions options = null)
|
public override string Defer(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");
|
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
@@ -490,7 +490,7 @@ namespace Discord.Rest
|
|||||||
/// <exception cref="InvalidOperationException"></exception>
|
/// <exception cref="InvalidOperationException"></exception>
|
||||||
public override string RespondWithModal(Modal modal, RequestOptions options = null)
|
public override string RespondWithModal(Modal modal, 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");
|
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace Discord.Rest
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public override string Defer(bool ephemeral = false, RequestOptions options = null)
|
public override string Defer(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!");
|
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
@@ -91,7 +91,7 @@ namespace Discord.Rest
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public string DeferLoading(bool ephemeral = false, RequestOptions options = null)
|
public string DeferLoading(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");
|
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
@@ -320,7 +320,7 @@ namespace Discord.Rest
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= Array.Empty<Embed>();
|
embeds ??= Array.Empty<Embed>();
|
||||||
@@ -486,7 +486,7 @@ namespace Discord.Rest
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
if (args.AllowedMentions.IsSpecified)
|
if (args.AllowedMentions.IsSpecified)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace Discord.Rest
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public string Respond(IEnumerable<AutocompleteResult> result, RequestOptions options = null)
|
public string Respond(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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace Discord.WebSocket
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= Array.Empty<Embed>();
|
embeds ??= Array.Empty<Embed>();
|
||||||
@@ -154,7 +154,7 @@ namespace Discord.WebSocket
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= Array.Empty<Embed>();
|
embeds ??= Array.Empty<Embed>();
|
||||||
@@ -218,7 +218,7 @@ namespace Discord.WebSocket
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
if (args.AllowedMentions.IsSpecified)
|
if (args.AllowedMentions.IsSpecified)
|
||||||
@@ -418,7 +418,7 @@ namespace Discord.WebSocket
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task DeferLoadingAsync(bool ephemeral = false, RequestOptions options = null)
|
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");
|
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
@@ -442,7 +442,7 @@ namespace Discord.WebSocket
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override async Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
|
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");
|
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
@@ -469,7 +469,7 @@ namespace Discord.WebSocket
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ namespace Discord.WebSocket
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= Array.Empty<Embed>();
|
embeds ??= Array.Empty<Embed>();
|
||||||
@@ -151,7 +151,7 @@ namespace Discord.WebSocket
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= Array.Empty<Embed>();
|
embeds ??= Array.Empty<Embed>();
|
||||||
@@ -215,7 +215,7 @@ namespace Discord.WebSocket
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
if (args.AllowedMentions.IsSpecified)
|
if (args.AllowedMentions.IsSpecified)
|
||||||
@@ -420,7 +420,7 @@ namespace Discord.WebSocket
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public override async Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
|
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");
|
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
@@ -450,7 +450,7 @@ namespace Discord.WebSocket
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task DeferLoadingAsync(bool ephemeral = false, RequestOptions options = null)
|
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");
|
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds of no response/acknowledgement");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace Discord.WebSocket
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task RespondAsync(IEnumerable<AutocompleteResult> result, RequestOptions options = null)
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ namespace Discord.WebSocket
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= Array.Empty<Embed>();
|
embeds ??= Array.Empty<Embed>();
|
||||||
@@ -143,7 +143,7 @@ namespace Discord.WebSocket
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
@@ -188,7 +188,7 @@ namespace Discord.WebSocket
|
|||||||
if (!IsValidToken)
|
if (!IsValidToken)
|
||||||
throw new InvalidOperationException("Interaction token is no longer valid");
|
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!");
|
throw new TimeoutException($"Cannot respond to an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
embeds ??= Array.Empty<Embed>();
|
embeds ??= Array.Empty<Embed>();
|
||||||
@@ -352,7 +352,7 @@ namespace Discord.WebSocket
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public override async Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
|
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!");
|
throw new TimeoutException($"Cannot defer an interaction after {InteractionHelper.ResponseTimeLimit} seconds!");
|
||||||
|
|
||||||
var response = new API.InteractionResponse
|
var response = new API.InteractionResponse
|
||||||
|
|||||||
Reference in New Issue
Block a user