Add getFullSlashCommand() method to get the SlashCommand annotation instance that has options if it is a rootcommand

This commit is contained in:
tueem 2024-10-29 23:03:09 +01:00
parent 0615741def
commit 0c3aeed4f4
No known key found for this signature in database
GPG Key ID: 819A0F7C36B9CF07

@ -3,7 +3,6 @@ package net.tomatentum.marinara.interaction.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import net.tomatentum.marinara.interaction.commands.annotation.SlashCommand;
@ -80,6 +79,17 @@ public class SlashCommandDefinition {
return (SubCommand[]) subCommandMap.values().toArray();
}
public SlashCommand getFullSlashCommand() {
if (isRootCommand())
return getSlashCommand();
for (ExecutableSlashCommandDefinition executableSlashCommandDefinition : executableDefinitons) {
if (executableSlashCommandDefinition.options().length > 0)
return executableSlashCommandDefinition.applicationCommand();
}
return null;
}
public SlashCommand getSlashCommand() {
return slashCommand;
}