Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added subcommands #16

Open
wants to merge 2 commits into
base: v5.0.0
Choose a base branch
from
Open

Added subcommands #16

wants to merge 2 commits into from

Conversation

PillageDev
Copy link

This PR adds the ability to have a command be registered as a subcommand and still function normally.

To create a subcommand, first you have to register a subcommand category off of the JDAIntegration object.

JDAIntegration commandIntegration = new JDAIntegration(jda);
commandIntegration.addSubCommandGroup(new CommandDataImpl("test", "test"));

To create a subcommand under that category, you have to edit the annotation on the method like the following:

@HandleSlash(name = "exampleCommand", desc = "Description", global = true, subCommand = true, parentGroup = "test")

If there is no subcommand group registered under a name "test" or any other command marked with that parent group name, then the program will throw a NoSuchElementException

If there is a better way to do any of this please let me know!

@PillageDev
Copy link
Author

I also fixed a small issue when you register a guild command then it would still say that there was an error registering it. That was caused by an issue with the if statement
Old:

if (guild != null) {
    guild.upsertCommand(data).queue();
} if (KCommando.verbose) {
    Kogger.warn("Guild not found for Slash Command named as " + name);
}

New:

if (guild != null) {
    guild.upsertCommand(commandData).queue();
    if (KCommando.verbose) {
        Kogger.info("The SlashCommand that named as '" + name + "' is upserted as a guild command for guild '" + guildId + 
        "'");
    }
} else { // Guild is null; not found
    if (KCommando.verbose) {
        Kogger.warn("Guild not found for Slash Command named as " + name);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant