Package com.reign.kat.lib.command
Class Command
java.lang.Object
com.reign.kat.lib.command.Command
- Direct Known Subclasses:
ButtonTestCommand
,ClearPlaylistCommand
,CommandExceptionTestCommand
,DebugParentCommand
,HelpCommand
,JoinCommand
,KillCommand
,LeaveCommand
,LevelCommand
,LoopCommand
,LyricsCommand
,MoveCommand
,NowPlayingCommand
,ParentCommand
,PlayCommand
,PlayNextCommand
,PrefixCommand
,QueueCommand
,RemoveCommand
,SeekCommand
,ShuffleCommand
,SkipCommand
,SlapCommand
,TestCommand
,TimingCommand
,VoiceRecogDebugCommand
,VoiceStateCommand
-
Field Summary
FieldsModifier and TypeFieldDescriptionList of argument Converters, parsed on command executionprotected static final org.slf4j.Logger
final String
Name of the CommandList of pre commands which are ran before command executionprotected int
Required Discord permission to run the commandprotected PermissionGroupType
Required permission to run the command -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConverter
(Converter<?> converter) Add a Converter to the commandvoid
addPreCommand
(BiFunction<Context, CommandParameters, PreCommandResult> precommand) Add a Pre command to the commandabstract void
execute
(Context ctx, CommandParameters args) void
executeCommands
(Context ctx, List<String> args) Calls the parent command before calling a subcommandgetName()
int
Returns the argument signature for the command.getSubcommand
(String alias) boolean
void
invokeCommand
(Context c, CommandParameters args) boolean
isPrivileged
(net.dv8tion.jda.api.entities.Member member, net.dv8tion.jda.api.entities.channel.concrete.TextChannel channel) boolean
void
registerSubcommand
(Command command) void
setRequiredDiscordPermission
(int permBitfield) Set the required Discord permissions a user must have to execute the command.void
setRequiredPermissionGroup
(PermissionGroupType permission) Set the required permission type a user must have to execute the command.void
setShowTyping
(boolean status) net.dv8tion.jda.api.interactions.commands.build.CommandData
-
Field Details
-
log
protected static final org.slf4j.Logger log -
name
Name of the Command -
requiredPermission
Required permission to run the command -
requiredDiscordPermission
protected int requiredDiscordPermissionRequired Discord permission to run the command -
converters
List of argument Converters, parsed on command execution -
precommands
List of pre commands which are ran before command execution
-
-
Constructor Details
-
Command
-
-
Method Details
-
addConverter
Add a Converter to the command -
addPreCommand
Add a Pre command to the command -
updateSlashData
public net.dv8tion.jda.api.interactions.commands.build.CommandData updateSlashData() -
registerSubcommand
-
getSubcommand
-
getAliases
-
getPrimaryAlias
-
getName
-
getDescription
-
setShowTyping
public void setShowTyping(boolean status) -
isShowTyping
public boolean isShowTyping() -
getRequiredCount
public int getRequiredCount() -
getSignature
Returns the argument signature for the command.
For example, the command!kick UserID opt:reason
would build a signature string of:-kick <user:User> [reason: String]
- Returns:
- String signature
-
setRequiredPermissionGroup
Set the required permission type a user must have to execute the command.- Parameters:
permission
- PermissionGroupType to limit execution to (and above).
-
setRequiredDiscordPermission
public void setRequiredDiscordPermission(int permBitfield) Set the required Discord permissions a user must have to execute the command. Examples:MANAGE_MESSAGES, ADMINISTRATOR`
.
It may be better to use setRequiredPermissionGroup instead, unless the command action would require a Discord permission - a command to delete messages, for example.- Parameters:
permBitfield
- DiscordPermission bitfield of permissions.
-
isPrivileged
public boolean isPrivileged(net.dv8tion.jda.api.entities.Member member, net.dv8tion.jda.api.entities.channel.concrete.TextChannel channel) -
execute
- Throws:
Exception
-
executeCommands
Calls the parent command before calling a subcommand- Parameters:
ctx
- Context of the commandargs
- string args to convert into Converters- Throws:
Exception
-
invokeCommand
- Throws:
Exception
-
hasChildren
public boolean hasChildren()
-