/// <summary>
        /// Enables slash commands on this <see cref="DiscordClient"/>
        /// </summary>
        /// <param name="client">Client to enable slash commands for</param>
        /// <param name="config">Configuration to use</param>
        /// <returns>Created <see cref="SlashCommandsExtension"/></returns>
        public static SlashCommandsExtension UseSlashCommands(this DiscordClient client)
        {
            if (client.GetExtension <SlashCommandsExtension>() != null)
            {
                throw new InvalidOperationException("Slash commands are already enabled for that client.");
            }

            var scomm = new SlashCommandsExtension();

            client.AddExtension(scomm);
            return(scomm);
        }
示例#2
0
 /// <summary>
 /// Creates a follow up message to the interaction
 /// </summary>
 /// <param name="webhook">The message to be sent, in the form of a webhook</param>
 /// <returns>The created message</returns>
 public async Task <DiscordMessage> FollowUpAsync(DiscordWebhookBuilder webhook)
 {
     return(await SlashCommandsExtension.CreateFollowupMessageAsync(Token, webhook));
 }
示例#3
0
 /// <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);
 }
示例#4
0
 /// <summary>
 /// Deletes the interaction response
 /// </summary>
 /// <returns></returns>
 public async Task DeleteResponseAsync()
 {
     await SlashCommandsExtension.DeleteInteractionResponseAsync(Token);
 }
示例#5
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);
 }