Class CommandBuilder
Commands.
This is more useful for creation of commands "mid-runtime".
A good usage would be to create a Command via eval and register it via
CommandClient#addCommand(Command).
While useful during runtime, this is completely inferior to extending Command as a superclass before compilation, and shouldn't be used in place of the ladder.
- Since:
- 1.6
- Author:
- Kaidan Gustave
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds aaliasfor the Command built from this CommandBuilder.addAliases(String... aliases) Addsaliasesfor the Command built from this CommandBuilder.Adds achildCommand to the Command built from this CommandBuilder.addChildren(Command... children) AddschildCommands to the Command built from this CommandBuilder.build(BiConsumer<Command, CommandEvent> execution) Builds theCommandusing the previously provided information.build(Consumer<CommandEvent> execution) Builds theCommandusing the previously provided information.setAliases(String... aliases) Sets thealiasesof the Command built from this CommandBuilder.setAliases(Collection<String> aliases) Sets thealiasesof the Command built from this CommandBuilder.setArguments(String arguments) Sets theargumentsof the Command built from this CommandBuilder.setBotPermissions(Collection<net.dv8tion.jda.api.Permission> botPermissions) Sets therequired bot permissionsof the Command built from this CommandBuilder.setBotPermissions(net.dv8tion.jda.api.Permission... botPermissions) Sets therequired bot permissionsof the Command built from this CommandBuilder.setCategory(Command.Category category) Sets thecategoryof the Command built from this CommandBuilder.setChildren(Command... children) Sets thechildrenof the Command built from this CommandBuilder.setChildren(Collection<Command> children) Sets thechildrenof the Command built from this CommandBuilder.setCooldown(int cooldown) Sets thecooldownof the Command built from this CommandBuilder.setCooldownScope(Command.CooldownScope cooldownScope) Sets thecooldown scopeof the Command built from this CommandBuilder.setGuildOnly(boolean guildOnly) Sets the Command built to beguild only.Sets thehelpsnippet of the Command built from this CommandBuilder.setHelpBiConsumer(BiConsumer<CommandEvent, Command> helpBiConsumer) Sets thehelp BiConsumerof the Command built from this CommandBuilder.setHidden(boolean hidden) Sets the Command built to behiddenfrom the help builder.Sets thenameof the Command built from this CommandBuilder.setOwnerCommand(boolean ownerCommand) Sets the Command built to beowner only.setRequiredRole(String requiredRole) Sets the name of arequired roleto use the Command built from this CommandBuilder.setUserPermissions(Collection<net.dv8tion.jda.api.Permission> userPermissions) Sets therequired user permissionsof the Command built from this CommandBuilder.setUserPermissions(net.dv8tion.jda.api.Permission... userPermissions) Sets therequired user permissionsof the Command built from this CommandBuilder.setUsesTopicTags(boolean usesTopicTags) Sets the Command built touse TopicTags.
-
Constructor Details
-
CommandBuilder
public CommandBuilder()
-
-
Method Details
-
setName
Sets thenameof the Command built from this CommandBuilder.- Parameters:
name- The name of the Command to be built.- Returns:
- This CommandBuilder
-
setHelp
Sets thehelpsnippet of the Command built from this CommandBuilder.- Parameters:
help- The help snippet of the Command to be built.- Returns:
- This CommandBuilder
-
setCategory
Sets thecategoryof the Command built from this CommandBuilder.- Parameters:
category- The category of the Command to be built.- Returns:
- This CommandBuilder
-
setArguments
Sets theargumentsof the Command built from this CommandBuilder.- Parameters:
arguments- The arguments of the Command to be built.- Returns:
- This CommandBuilder
-
setGuildOnly
Sets the Command built to beguild only.- Parameters:
guildOnly-trueif the Command built is guild only,falseif it is not.- Returns:
- This CommandBuilder
-
setRequiredRole
Sets the name of arequired roleto use the Command built from this CommandBuilder.- Parameters:
requiredRole- The name of a role required to use the Command to be built.- Returns:
- This CommandBuilder
-
setOwnerCommand
Sets the Command built to beowner only.- Parameters:
ownerCommand-trueif the Command built is owner only,falseif it is not.- Returns:
- This CommandBuilder
-
setCooldown
Sets thecooldownof the Command built from this CommandBuilder.- Parameters:
cooldown- The number of seconds the built Command will be on cooldown.- Returns:
- This CommandBuilder
-
setUserPermissions
Sets therequired user permissionsof the Command built from this CommandBuilder.- Parameters:
userPermissions- The required Permissions a User must have when using the Command to be built.- Returns:
- This CommandBuilder
-
setUserPermissions
public CommandBuilder setUserPermissions(Collection<net.dv8tion.jda.api.Permission> userPermissions) Sets therequired user permissionsof the Command built from this CommandBuilder.- Parameters:
userPermissions- The required Permissions a User must have when using the Command to be built.- Returns:
- This CommandBuilder
-
setBotPermissions
Sets therequired bot permissionsof the Command built from this CommandBuilder.- Parameters:
botPermissions- The required Permissions the bot must have when using the Command to be built.- Returns:
- This CommandBuilder
-
setBotPermissions
Sets therequired bot permissionsof the Command built from this CommandBuilder.- Parameters:
botPermissions- The required Permissions the bot must have when using the Command to be built.- Returns:
- This CommandBuilder
-
addAlias
Adds aaliasfor the Command built from this CommandBuilder.- Parameters:
alias- The Command alias to add.- Returns:
- This CommandBuilder.
-
addAliases
Addsaliasesfor the Command built from this CommandBuilder.- Parameters:
aliases- The Command aliases to add.- Returns:
- This CommandBuilder.
-
setAliases
Sets thealiasesof the Command built from this CommandBuilder.- Parameters:
aliases- The aliases of the Command to be built.- Returns:
- This CommandBuilder
-
setAliases
Sets thealiasesof the Command built from this CommandBuilder.- Parameters:
aliases- The aliases of the Command to be built.- Returns:
- This CommandBuilder
-
addChild
Adds achildCommand to the Command built from this CommandBuilder.- Parameters:
child- The child Command to add.- Returns:
- This CommandBuilder.
-
addChildren
AddschildCommands to the Command built from this CommandBuilder.- Parameters:
children- The child Commands to add.- Returns:
- This CommandBuilder.
-
setChildren
Sets thechildrenof the Command built from this CommandBuilder.- Parameters:
children- The children of the Command to be built.- Returns:
- This CommandBuilder
-
setChildren
Sets thechildrenof the Command built from this CommandBuilder.- Parameters:
children- The children of the Command to be built.- Returns:
- This CommandBuilder
-
setHelpBiConsumer
Sets thehelp BiConsumerof the Command built from this CommandBuilder.- Parameters:
helpBiConsumer- The help BiConsumer of the Command to be built.- Returns:
- This CommandBuilder
-
setUsesTopicTags
Sets the Command built touse TopicTags.- Parameters:
usesTopicTags-trueif the Command built is uses topic tags,falseif it does not.- Returns:
- This CommandBuilder
-
setCooldownScope
Sets thecooldown scopeof the Command built from this CommandBuilder.- Parameters:
cooldownScope- The CooldownScope of the Command to be built.- Returns:
- This CommandBuilder
-
setHidden
Sets the Command built to behiddenfrom the help builder.- Parameters:
hidden-trueif this will be hidden from the help builder,falseotherwise.- Returns:
- This CommandBuilder
-
build
Builds theCommandusing the previously provided information.This uses the only the
CommandEventparameter that would be provided during#execute(CommandEvent), and no information about the Command can be retrieved using this.An alternate method
build(java.util.function.BiConsumer)exists if you wish to retrieve information about the Command built during execution.- Parameters:
execution- TheConsumerthat runs on Command#execute(CommandEvent).- Returns:
- The Command built
-
build
Builds theCommandusing the previously provided information.This uses the both the
CommandEventparameter that would be provided during#execute(CommandEvent), and the Command built when, allowing info on the Command to be retrieved during execution.- Parameters:
execution- TheBiConsumerthat runs onCommand.execute(CommandEvent).- Returns:
- The Command built
-