From 0c3aeed4f419aa22b8499fba0072ba66120c9f2a Mon Sep 17 00:00:00 2001 From: tueem Date: Tue, 29 Oct 2024 23:03:09 +0100 Subject: [PATCH] Add getFullSlashCommand() method to get the SlashCommand annotation instance that has options if it is a rootcommand --- .../interaction/commands/SlashCommandDefinition.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/src/main/java/net/tomatentum/marinara/interaction/commands/SlashCommandDefinition.java b/lib/src/main/java/net/tomatentum/marinara/interaction/commands/SlashCommandDefinition.java index e0d19aa..999a44b 100644 --- a/lib/src/main/java/net/tomatentum/marinara/interaction/commands/SlashCommandDefinition.java +++ b/lib/src/main/java/net/tomatentum/marinara/interaction/commands/SlashCommandDefinition.java @@ -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; }