#Sub Commands, how to create?

1 messages · Page 1 of 1 (latest)

next kettle
#

I'm using code via the modular approach for commands, however, I'm not sure how to add subcommands to it ? The doc's have it laid out as

https://discordnet.dev/guides/int_basics/application-commands/slash-commands/subcommands.html

But, I'm trying to write it as

using Discord;
using Discord.Interactions;


namespace UtilitiesBot.Discord.Commands.Moderation
{
    public partial class ServerCommands : InteractionModuleBase<SocketInteractionContext>
    {
        private ILogger _logger = DiscordBot.GetLogger();
        
        [SlashCommand("clear", "Clear messages!")]
        public async Task Clear(
            [Summary("messageCount", "Count of Messages to Clear")]
            int messageCount = 1)
        {
[CODEHERE]
        }
    }
}
#

I'm attempting to make a command

/character <new|delete|show> "Character Name" with or without quotes.```
#

There will be multiple subcommands underneath it, I just need to figure out how to get it setup

sweet wren
next kettle
#

Using the interaction service, you can do options / prefilled. However, the end goal is that it will be sub commands w/ the eventual different input

eternal bone
#

It's confusing on how you're intending to make it look. Based on the docs, though, here's what the modular approach looks like:

[Group("foo", "Subcommand group")]
        public class ExampleModule : InteractionModuleBase<SocketInteractionContext>
        {
            [SlashCommand("bar", "First subcommand")]
            public async Task barFunction()
            {
                // Stuff
            }
            [SlashCommand("notbar", "Second subcommand")]
            public async Task notBarFunction()
            {
                // More stuff
            }
            [SlashCommand("morenotbar", "Third subcommand")]
            public async Task moreNotBarFunction()
            {
                // Even more stuff
            }
        }

In this case, a user will always have to type /foo in order to get to /foo bar or any other variant. The root command /foo, however, by itself will do nothing. On the front-end, commands will look like this:
/foo bar
/foo notbar
/foo morenotbar

next kettle
#

Got it now, Thanks!

#

Ya'll awesome 🙂