//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));
        }
Exemple #2
0
 /// <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);
 }