public class CommandBuilder
extends java.lang.Object
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.
Constructor and Description |
---|
CommandBuilder() |
Modifier and Type | Method and Description |
---|---|
CommandBuilder |
addAlias(java.lang.String alias)
Adds a
alias
for the Command built from this CommandBuilder. |
CommandBuilder |
addAliases(java.lang.String... aliases)
Adds
aliases
for the Command built from this CommandBuilder. |
CommandBuilder |
addChild(Command child)
Adds a
child
Command to the Command built from this CommandBuilder. |
CommandBuilder |
addChildren(Command... children)
Adds
child
Commands to the Command built from this CommandBuilder. |
Command |
build(java.util.function.BiConsumer<Command,CommandEvent> execution)
Builds the
Command
using the previously provided information. |
Command |
build(java.util.function.Consumer<CommandEvent> execution)
Builds the
Command
using the previously provided information. |
CommandBuilder |
setAliases(java.util.Collection<java.lang.String> aliases)
Sets the
aliases
of the Command built from this CommandBuilder. |
CommandBuilder |
setAliases(java.lang.String... aliases)
Sets the
aliases
of the Command built from this CommandBuilder. |
CommandBuilder |
setArguments(java.lang.String arguments)
Sets the
arguments
of the Command built from this CommandBuilder. |
CommandBuilder |
setBotPermissions(java.util.Collection<net.dv8tion.jda.core.Permission> botPermissions)
Sets the
required bot permissions of the Command built from this CommandBuilder. |
CommandBuilder |
setBotPermissions(net.dv8tion.jda.core.Permission... botPermissions)
Sets the
required bot permissions of the Command built from this CommandBuilder. |
CommandBuilder |
setCategory(Command.Category category)
Sets the
category
of the Command built from this CommandBuilder. |
CommandBuilder |
setChildren(java.util.Collection<Command> children)
Sets the
children
of the Command built from this CommandBuilder. |
CommandBuilder |
setChildren(Command... children)
Sets the
children
of the Command built from this CommandBuilder. |
CommandBuilder |
setCooldown(int cooldown)
Sets the
cooldown
of the Command built from this CommandBuilder. |
CommandBuilder |
setCooldownScope(Command.CooldownScope cooldownScope)
Sets the
cooldown scope of the Command built from this CommandBuilder. |
CommandBuilder |
setGuildOnly(boolean guildOnly)
Sets the Command built to be
guild only . |
CommandBuilder |
setHelp(java.lang.String help)
Sets the
help
snippet of the Command built from this CommandBuilder. |
CommandBuilder |
setHelpBiConsumer(java.util.function.BiConsumer<CommandEvent,Command> helpBiConsumer)
Sets the
help BiConsumer of the Command built from this CommandBuilder. |
CommandBuilder |
setHidden(boolean hidden)
Sets the Command built to be
hidden
from the help builder. |
CommandBuilder |
setName(java.lang.String name)
Sets the
name
of the Command built from this CommandBuilder. |
CommandBuilder |
setOwnerCommand(boolean ownerCommand)
Sets the Command built to be
owner only . |
CommandBuilder |
setRequiredRole(java.lang.String requiredRole)
Sets the name of a
required role to use the Command built from this CommandBuilder. |
CommandBuilder |
setUserPermissions(java.util.Collection<net.dv8tion.jda.core.Permission> userPermissions)
Sets the
required user permissions of the Command built from this CommandBuilder. |
CommandBuilder |
setUserPermissions(net.dv8tion.jda.core.Permission... userPermissions)
Sets the
required user permissions of the Command built from this CommandBuilder. |
CommandBuilder |
setUsesTopicTags(boolean usesTopicTags)
Sets the Command built to
use TopicTags . |
public CommandBuilder setName(java.lang.String name)
name
of the Command built from this CommandBuilder.name
- The name of the Command to be built.public CommandBuilder setHelp(java.lang.String help)
help
snippet of the Command built from this CommandBuilder.help
- The help snippet of the Command to be built.public CommandBuilder setCategory(Command.Category category)
category
of the Command built from this CommandBuilder.category
- The category of the Command to be built.public CommandBuilder setArguments(java.lang.String arguments)
arguments
of the Command built from this CommandBuilder.arguments
- The arguments of the Command to be built.public CommandBuilder setGuildOnly(boolean guildOnly)
guild only
.guildOnly
- true
if the Command built is guild only, false
if it is not.public CommandBuilder setRequiredRole(java.lang.String requiredRole)
required role
to use the Command built from this CommandBuilder.requiredRole
- The name of a role required to use the Command to be built.public CommandBuilder setOwnerCommand(boolean ownerCommand)
owner only
.ownerCommand
- true
if the Command built is owner only, false
if it is not.public CommandBuilder setCooldown(int cooldown)
cooldown
of the Command built from this CommandBuilder.cooldown
- The number of seconds the built Command will be on cooldown.public CommandBuilder setUserPermissions(net.dv8tion.jda.core.Permission... userPermissions)
required user permissions
of the Command built from this CommandBuilder.userPermissions
- The required Permissions a User must have when using the Command to be built.public CommandBuilder setUserPermissions(java.util.Collection<net.dv8tion.jda.core.Permission> userPermissions)
required user permissions
of the Command built from this CommandBuilder.userPermissions
- The required Permissions a User must have when using the Command to be built.public CommandBuilder setBotPermissions(net.dv8tion.jda.core.Permission... botPermissions)
required bot permissions
of the Command built from this CommandBuilder.botPermissions
- The required Permissions the bot must have when using the Command to be built.public CommandBuilder setBotPermissions(java.util.Collection<net.dv8tion.jda.core.Permission> botPermissions)
required bot permissions
of the Command built from this CommandBuilder.botPermissions
- The required Permissions the bot must have when using the Command to be built.public CommandBuilder addAlias(java.lang.String alias)
alias
for the Command built from this CommandBuilder.alias
- The Command alias to add.public CommandBuilder addAliases(java.lang.String... aliases)
aliases
for the Command built from this CommandBuilder.aliases
- The Command aliases to add.public CommandBuilder setAliases(java.lang.String... aliases)
aliases
of the Command built from this CommandBuilder.aliases
- The aliases of the Command to be built.public CommandBuilder setAliases(java.util.Collection<java.lang.String> aliases)
aliases
of the Command built from this CommandBuilder.aliases
- The aliases of the Command to be built.public CommandBuilder addChild(Command child)
child
Command to the Command built from this CommandBuilder.child
- The child Command to add.public CommandBuilder addChildren(Command... children)
child
Commands to the Command built from this CommandBuilder.children
- The child Commands to add.public CommandBuilder setChildren(Command... children)
children
of the Command built from this CommandBuilder.children
- The children of the Command to be built.public CommandBuilder setChildren(java.util.Collection<Command> children)
children
of the Command built from this CommandBuilder.children
- The children of the Command to be built.public CommandBuilder setHelpBiConsumer(java.util.function.BiConsumer<CommandEvent,Command> helpBiConsumer)
help BiConsumer
of the Command built from this CommandBuilder.helpBiConsumer
- The help BiConsumer of the Command to be built.public CommandBuilder setUsesTopicTags(boolean usesTopicTags)
use TopicTags
.usesTopicTags
- true
if the Command built is uses topic tags, false
if it does not.public CommandBuilder setCooldownScope(Command.CooldownScope cooldownScope)
cooldown scope
of the Command built from this CommandBuilder.cooldownScope
- The CooldownScope of the Command to be built.public CommandBuilder setHidden(boolean hidden)
hidden
from the help builder.hidden
- true
if this will be hidden from the help builder, false
otherwise.public Command build(java.util.function.Consumer<CommandEvent> execution)
Command
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.
execution
- The Consumer
that runs on Command#execute(CommandEvent).public Command build(java.util.function.BiConsumer<Command,CommandEvent> execution)
Command
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.
execution
- The BiConsumer
that runs on Command.execute(CommandEvent)
.