/// <summary> /// Updates the original interaction response. /// </summary> /// <param name="edit">New version of the response</param> /// <returns>Update task</returns> internal async Task <DiscordMessage?> UpdateAsync(InteractionResponse edit, string token) { if (_config.DefaultResponseType == Enums.InteractionResponseType.Acknowledge || _config.DefaultResponseType == Enums.InteractionResponseType.ACKWithSource) { throw new Exception("Can't edit default response when using Acknowledge or ACKWithSource."); } var request = new HttpRequestMessage() { Method = HttpMethod.Patch, RequestUri = GetEditOrDeleteInitialUri(token), Content = new StringContent(edit.BuildWebhookEditBody(_jsonSettings)), }; request.Content.Headers.ContentType = new(_contentType); var res = await _http.SendAsync(request); if (res.IsSuccessStatusCode) { return(await GetResponseBody(res)); } else { return(null); } }
/// <summary> /// Edits a followup message from a response. /// </summary> /// <param name="message">New message to replace the old one with.</param> /// <param name="token">Original response token.</param> /// <param name="id">Id of the followup message that you want to edit.</param> /// <returns>Edit task</returns> internal async Task <DiscordMessage?> EditAsync(InteractionResponse edit, string token, ulong id) { var request = new HttpRequestMessage() { Method = HttpMethod.Patch, RequestUri = GetEditFollowupUri(token, id), Content = new StringContent(edit.BuildWebhookEditBody(_jsonSettings)), }; request.Content.Headers.ContentType = new(_contentType); var res = await _http.SendAsync(request); if (res.IsSuccessStatusCode) { return(await GetResponseBody(res)); } else { return(null); } }