public class CommandSettings extends Object
When you want your commands to become active, use activate()
| Modifier and Type | Field | Description |
|---|---|---|
static String |
VALID_LABEL |
|
static String |
VALID_PREFIX |
| Constructor | Description |
|---|---|
CommandSettings(String defaultPrefix,
net.dv8tion.jda.bot.sharding.ShardManager shardManager,
boolean useHelpCommand,
boolean labelIgnoreCase) |
This is the optional constructor in case you are sharding your bot.
|
CommandSettings(String defaultPrefix,
net.dv8tion.jda.core.JDA jda,
boolean useHelpCommand,
boolean labelIgnoreCase) |
This is the constructor.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
activate() |
Sets the prefix and the command HashMap for the rest of the API.
|
void |
deactivate() |
Deactivates the current CommandSettings by removing the command listener from jda.
|
protected Map<String,ICommand> |
getCommands() |
|
protected Set<String> |
getHelpLabels() |
|
String |
getPrefix() |
Use this method to get the default prefix.
|
String |
getPrefix(long guildId) |
Use this method to get the prefix for a specific guild.
|
protected boolean |
labelIgnoreCase() |
|
CommandSettings |
put(ICommand command,
String label) |
Use this method to add commands from your project.
|
CommandSettings |
put(ICommand command,
String... labels) |
Use this method to add commands with aliases.
|
boolean |
remove(String label) |
Use this method to remove existing commands.
|
boolean |
remove(String... labels) |
Use this method to remove more than one command at a time.
|
void |
setCustomPrefix(long guildId,
String prefix) |
Use this method to add a custom command prefix to a guild.
|
void |
setDefaultPrefix(String prefix) |
Use this method to set the default prefix.
|
CommandSettings |
setHelpLabel(String... labels) |
Use this method to add help labels.
|
protected boolean |
useHelpCommand() |
public static final String VALID_PREFIX
public static final String VALID_LABEL
public CommandSettings(@Nonnull String defaultPrefix, @Nonnull net.dv8tion.jda.bot.sharding.ShardManager shardManager, boolean useHelpCommand, boolean labelIgnoreCase)
shardManager - Put your active ShardManager here. This is important for the activation of the CommandListener.defaultPrefix - The String you will have to put before every command in order to get your command execution registered. This can later be changed.useHelpCommand - Set this to true, if you want to use the auto-generated help command of this API. You can configure this by setting the help
labels with setHelpLabel(String...) and by overriding the method info() in your command classes.labelIgnoreCase - Set this to true, if you want deactivate case sensitivity for the recognition of labels. E.g.: there will be no difference between the labels "foo",
"FOO", "FoO" and so on.public CommandSettings(@Nonnull String defaultPrefix, @Nonnull net.dv8tion.jda.core.JDA jda, boolean useHelpCommand, boolean labelIgnoreCase)
jda - Put your active JDA here. This is important for the activation of the CommandListener.defaultPrefix - The String you will have to put before every command in order to get your command execution registered. This can later be changed.useHelpCommand - Set this to true, if you want to use the auto-generated help command of this API. You can configure this by setting the help
labels with setHelpLabel(String...) and by overriding the method info() in your command classes.labelIgnoreCase - Set this to true, if you want deactivate case sensitivity for the recognition of labels. E.g.: there will be no difference between the labels "foo",
* "FOO", "FoO" and so on.public CommandSettings setHelpLabel(String... labels)
labels - One or more labels which may later be called by members to list all commands or to show info about one specific command.public CommandSettings put(@Nonnull ICommand command, @Nonnull String label)
The two parameters will be put in a HashMap which is used by the API to notice commands.
label - The label which describes your command, i.e. the string after the prefix [prefix][label].command - An instance of your command class which implements ICommand.CommandSetException - If the label is empty or consists of multiple words.public CommandSettings put(@Nonnull ICommand command, @Nonnull String... labels)
Works like put(ICommand, String) but adds multiple labels to the same command.
command - An instance of your command class which implements ICommand.labels - One or more labels. This will throw a CommandSetException, if the label is empty or contains spaces.public boolean remove(@Nonnull String label)
label - The label of the command to remove.public boolean remove(@Nonnull String... labels)
labels - One or more labels to removepublic void setDefaultPrefix(@Nonnull String prefix)
prefix - The prefix to set. In case the given String is empty, this will throw a CommandSetException.CommandSetException - if the prefix is empty.public void setCustomPrefix(long guildId,
String prefix)
guildId - The guild id as a long.prefix - The prefix to be set.CommandSetException - if a non-null prefix is empty.public void activate()
Note that activating multiple CommandSettings may cause problems. You can do this to use multiple prefixes, but it is not recommended.
This method is important to call because otherwise no command will be registered by the internal command listener.
CommandSetException - if you already activated this instance.public void deactivate()
CommandSetException - if you either did not activate this instance or already deactivated it.public String getPrefix(long guildId)
guildId - The id of the guild to check.public String getPrefix()
protected boolean labelIgnoreCase()
protected boolean useHelpCommand()
Copyright © 2018. All rights reserved.