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
-
Method Summary
Modifier and TypeMethodDescriptionAdds aalias
for the Command built from this CommandBuilder.addAliases
(String... aliases) Addsaliases
for the Command built from this CommandBuilder.Adds achild
Command to the Command built from this CommandBuilder.addChildren
(Command... children) Addschild
Commands to the Command built from this CommandBuilder.build
(BiConsumer<Command, CommandEvent> execution) Builds theCommand
using the previously provided information.build
(Consumer<CommandEvent> execution) Builds theCommand
using the previously provided information.setAliases
(String... aliases) Sets thealiases
of the Command built from this CommandBuilder.setAliases
(Collection<String> aliases) Sets thealiases
of the Command built from this CommandBuilder.setArguments
(String arguments) Sets thearguments
of the Command built from this CommandBuilder.setBotPermissions
(Collection<net.dv8tion.jda.api.Permission> botPermissions) Sets therequired bot permissions
of the Command built from this CommandBuilder.setBotPermissions
(net.dv8tion.jda.api.Permission... botPermissions) Sets therequired bot permissions
of the Command built from this CommandBuilder.setCategory
(Command.Category category) Sets thecategory
of the Command built from this CommandBuilder.setChildren
(Command... children) Sets thechildren
of the Command built from this CommandBuilder.setChildren
(Collection<Command> children) Sets thechildren
of the Command built from this CommandBuilder.setCooldown
(int cooldown) Sets thecooldown
of the Command built from this CommandBuilder.setCooldownScope
(CooldownScope cooldownScope) Sets thecooldown scope
of the Command built from this CommandBuilder.setGuildOnly
(boolean guildOnly) Sets the Command built to beguild only
.Sets thehelp
snippet of the Command built from this CommandBuilder.setHelpBiConsumer
(BiConsumer<CommandEvent, Command> helpBiConsumer) Sets thehelp BiConsumer
of the Command built from this CommandBuilder.setHidden
(boolean hidden) Sets the Command built to behidden
from the help builder.Sets thename
of the Command built from this CommandBuilder.setOwnerCommand
(boolean ownerCommand) Sets the Command built to beowner only
.setRequiredRole
(String requiredRole) Sets the name of arequired role
to use the Command built from this CommandBuilder.setUserPermissions
(Collection<net.dv8tion.jda.api.Permission> userPermissions) Sets therequired user permissions
of the Command built from this CommandBuilder.setUserPermissions
(net.dv8tion.jda.api.Permission... userPermissions) Sets therequired user permissions
of the Command built from this CommandBuilder.setUsesTopicTags
(boolean usesTopicTags) Sets the Command built touse TopicTags
.
-
Constructor Details
-
CommandBuilder
public CommandBuilder()
-
-
Method Details
-
setName
Sets thename
of the Command built from this CommandBuilder.- Parameters:
name
- The name of the Command to be built.- Returns:
- This CommandBuilder
-
setHelp
Sets thehelp
snippet of the Command built from this CommandBuilder.- Parameters:
help
- The help snippet of the Command to be built.- Returns:
- This CommandBuilder
-
setCategory
Sets thecategory
of the Command built from this CommandBuilder.- Parameters:
category
- The category of the Command to be built.- Returns:
- This CommandBuilder
-
setArguments
Sets thearguments
of 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
-true
if the Command built is guild only,false
if it is not.- Returns:
- This CommandBuilder
-
setRequiredRole
Sets the name of arequired role
to 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
-true
if the Command built is owner only,false
if it is not.- Returns:
- This CommandBuilder
-
setCooldown
Sets thecooldown
of 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 permissions
of 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 permissions
of 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 permissions
of 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 permissions
of 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 aalias
for the Command built from this CommandBuilder.- Parameters:
alias
- The Command alias to add.- Returns:
- This CommandBuilder.
-
addAliases
Addsaliases
for the Command built from this CommandBuilder.- Parameters:
aliases
- The Command aliases to add.- Returns:
- This CommandBuilder.
-
setAliases
Sets thealiases
of the Command built from this CommandBuilder.- Parameters:
aliases
- The aliases of the Command to be built.- Returns:
- This CommandBuilder
-
setAliases
Sets thealiases
of the Command built from this CommandBuilder.- Parameters:
aliases
- The aliases of the Command to be built.- Returns:
- This CommandBuilder
-
addChild
Adds achild
Command to the Command built from this CommandBuilder.- Parameters:
child
- The child Command to add.- Returns:
- This CommandBuilder.
-
addChildren
Addschild
Commands to the Command built from this CommandBuilder.- Parameters:
children
- The child Commands to add.- Returns:
- This CommandBuilder.
-
setChildren
Sets thechildren
of the Command built from this CommandBuilder.- Parameters:
children
- The children of the Command to be built.- Returns:
- This CommandBuilder
-
setChildren
Sets thechildren
of the Command built from this CommandBuilder.- Parameters:
children
- The children of the Command to be built.- Returns:
- This CommandBuilder
-
setHelpBiConsumer
Sets thehelp BiConsumer
of 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
-true
if the Command built is uses topic tags,false
if it does not.- Returns:
- This CommandBuilder
-
setCooldownScope
Sets thecooldown scope
of 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 behidden
from the help builder.- Parameters:
hidden
-true
if this will be hidden from the help builder,false
otherwise.- Returns:
- This CommandBuilder
-
build
Builds theCommand
using the previously provided information.This uses the only the
CommandEvent
parameter 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
- TheConsumer
that runs on Command#execute(CommandEvent).- Returns:
- The Command built
-
build
Builds theCommand
using the previously provided information.This uses the both the
CommandEvent
parameter that would be provided during#execute(CommandEvent)
, and the Command built when, allowing info on the Command to be retrieved during execution.- Parameters:
execution
- TheBiConsumer
that runs onCommand.execute(CommandEvent)
.- Returns:
- The Command built
-