/// <summary> /// Edits the interaction response /// </summary> /// <param name="token">The token of the interaction</param> /// <param name="builder">The data, if any, to edit the response with</param> /// <returns></returns> public async Task EditInteractionResponseAsync(string token, DiscordInteractionBuilder builder) { var route = $"/webhooks/{Client.CurrentApplication.Id}/{token}/messages/@original"; var bucket = Client.ApiClient.Rest.GetBucket(RestRequestMethod.PATCH, route, new { }, out var path); var url = Utilities.GetApiUriFor(path); await Client.ApiClient.DoRequestAsync(Client, bucket, url, RestRequestMethod.PATCH, route, payload : DiscordJson.SerializeObject(builder)); }
/// <summary> /// Edits the interaction response /// </summary> /// <param name="builder">The data to edit the response with</param> /// <returns></returns> public async Task EditResponseAsync(DiscordInteractionBuilder builder) { await SlashCommandsExtension.EditInteractionResponseAsync(Token, builder); }
//Respond methods /// <summary> /// Creates a response to an interaction /// </summary> /// <param name="interactionId">The id of the interaction</param> /// <param name="token">The token of the interaction</param> /// <param name="type">The type to respond with</param> /// <param name="builder">The data, if any, to send</param> /// <returns></returns> public async Task CreateInteractionResponseAsync(ulong interactionId, string token, DiscordInteractionResponseType type, DiscordInteractionBuilder builder = null) { var pld = new InteractionCreatePayload { Type = type, Data = builder }; var route = $"/interactions/{interactionId}/{token}/callback"; var bucket = Client.ApiClient.Rest.GetBucket(RestRequestMethod.POST, route, new { }, out var path); var url = Utilities.GetApiUriFor(path); await Client.ApiClient.DoRequestAsync(Client, bucket, url, RestRequestMethod.POST, route, payload : DiscordJson.SerializeObject(pld)); }
/// <summary> /// Creates a response to this interaction /// <para>You must create a response within 3 seconds of this interaction being executed; if the command has the potential to take more than 3 seconds, create a <see cref="DiscordInteractionResponseType.DeferredChannelMessageWithSource"/> at the start, and edit the response later</para> /// </summary> /// <param name="type">The type of the response</param> /// <param name="builder">The data to be sent, if any</param> /// <returns></returns> public async Task CreateResponseAsync(DiscordInteractionResponseType type, DiscordInteractionBuilder builder = null) { await SlashCommandsExtension.CreateInteractionResponseAsync(InteractionId, Token, type, builder); }