Class SlashCommand
java.lang.Object
xyz.dynxsty.dih4jda.interactions.commands.RestrictedCommand
xyz.dynxsty.dih4jda.interactions.commands.application.ApplicationCommand<E,T>
xyz.dynxsty.dih4jda.interactions.commands.application.BaseApplicationCommand<net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent,net.dv8tion.jda.api.interactions.commands.build.SlashCommandData>
xyz.dynxsty.dih4jda.interactions.commands.application.SlashCommand
- All Implemented Interfaces:
ExecutableCommand<net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent>
public abstract class SlashCommand
extends BaseApplicationCommand<net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent,net.dv8tion.jda.api.interactions.commands.build.SlashCommandData>
Represents a single Slash Command.
- Since:
- v1.5
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classModel class which represents a single Subcommand.static classModel class which represents a single subcommand group.Nested classes/interfaces inherited from class xyz.dynxsty.dih4jda.interactions.commands.RestrictedCommand
RestrictedCommand.Cooldown -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddSubcommandGroups(SlashCommand.SubcommandGroup... groups) Sets all Subcommand Groups that belong to this "base" command.final voidaddSubcommands(SlashCommand.Subcommand... classes) Sets all Subcommands that belong to this "base" command.net.dv8tion.jda.api.interactions.commands.CommandGets the correspondingJDA entityfor this command.voidexecute(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event) The method that gets called once the command gets executed.final SlashCommand.SubcommandGroup[]final SlashCommand.Subcommand[]Methods inherited from class xyz.dynxsty.dih4jda.interactions.commands.application.BaseApplicationCommand
getQueueableGuilds, getRegistrationType, setQueueableGuilds, setRegistrationTypeMethods inherited from class xyz.dynxsty.dih4jda.interactions.commands.application.ApplicationCommand
getCommandData, setCommandDataMethods inherited from class xyz.dynxsty.dih4jda.interactions.commands.RestrictedCommand
applyCooldown, getCommandCooldown, getRequiredGuilds, getRequiredPermissions, getRequiredRoles, getRequiredUsers, hasCooldown, retrieveCooldown, setCommandCooldown, setRequiredGuilds, setRequiredPermissions, setRequiredRoles, setRequiredUsers
-
Method Details
-
getSubcommands
-
addSubcommands
Sets all Subcommands that belong to this "base" command.- Parameters:
classes- The classes (must extendSlashCommand.Subcommand) which should be registered as subcommands.
-
getSubcommandGroups
-
addSubcommandGroups
Sets all Subcommand Groups that belong to this "base" command.- Parameters:
groups- A map of theSubcommandGroupDataand their correspondingSlashCommand.Subcommands.
-
execute
public void execute(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event) Description copied from interface:ExecutableCommandThe method that gets called once the command gets executed.- Parameters:
event- the command that is getting passed.
-
asCommand
@Nullable public net.dv8tion.jda.api.interactions.commands.Command asCommand()Gets the correspondingJDA entityfor this command. If the command was not cached or queued before (e.g. when using sharding), this may return null.- Returns:
- The
Commandcorresponding to this class.
-