public class CommandClientBuilder
extends java.lang.Object
CommandClientImpl
.
Once built, add the CommandClient
as an EventListener to
JDA
and it will automatically handle commands with ease!
Constructor and Description |
---|
CommandClientBuilder() |
Modifier and Type | Method and Description |
---|---|
CommandClientBuilder |
addAnnotatedModule(java.lang.Object module)
Adds an annotated command module to the
CommandClientImpl for this session. |
CommandClientBuilder |
addAnnotatedModules(java.lang.Object... modules)
Adds multiple annotated command modules to the
CommandClientImpl for this session. |
CommandClientBuilder |
addCommand(Command command)
Adds a
Command and registers it to the
CommandClientImpl for this session. |
CommandClientBuilder |
addCommands(Command... commands)
Adds and registers multiple
Command s to the
CommandClientImpl for this session. |
CommandClient |
build()
Builds a
CommandClientImpl
with the provided settings. |
CommandClientBuilder |
setAlternativePrefix(java.lang.String prefix)
Sets the bot's alternative prefix.
|
CommandClientBuilder |
setAnnotatedCompiler(AnnotatedModuleCompiler compiler)
Sets the
AnnotatedModuleCompiler
for this CommandClientBuilder. |
CommandClientBuilder |
setCarbonitexKey(java.lang.String key)
Sets the Carbonitex key for this bot's listing.
|
CommandClientBuilder |
setCoOwnerIds(java.lang.String... coOwnerIds)
Sets the one or more CoOwners of the bot.
|
CommandClientBuilder |
setDiscordBotListKey(java.lang.String key)
Sets the Discord Bot List API key for this bot's listing.
|
CommandClientBuilder |
setDiscordBotsKey(java.lang.String key)
Sets the Discord Bots API key for this bot's listing.
|
CommandClientBuilder |
setEmojis(java.lang.String success,
java.lang.String warning,
java.lang.String error)
Sets the emojis for success, warning, and failure.
|
CommandClientBuilder |
setGame(net.dv8tion.jda.core.entities.Game game)
Sets the
Game to use when the bot is ready. |
CommandClientBuilder |
setGuildSettingsManager(GuildSettingsManager manager)
Sets the
GuildSettingsManager
for the CommandClientImpl built using this builder. |
CommandClientBuilder |
setHelpConsumer(java.util.function.Consumer<CommandEvent> helpConsumer)
Sets the consumer to run as the bot's help command.
|
CommandClientBuilder |
setHelpWord(java.lang.String helpWord)
Sets the word used to trigger the command list.
|
CommandClientBuilder |
setLinkedCacheSize(int linkedCacheSize)
Sets the internal size of the client's
FixedSizeCache
used for caching and pairing the bot's response Message s with
the calling Message's ID. |
CommandClientBuilder |
setListener(CommandListener listener)
Sets the
CommandListener for the
CommandClientImpl . |
CommandClientBuilder |
setOwnerId(java.lang.String ownerId)
Sets the owner for the bot.
|
CommandClientBuilder |
setPrefix(java.lang.String prefix)
Sets the bot's prefix.
|
CommandClientBuilder |
setScheduleExecutor(java.util.concurrent.ScheduledExecutorService executor)
Sets the
ScheduledExecutorService for the
CommandClientImpl . |
CommandClientBuilder |
setServerInvite(java.lang.String serverInvite)
Sets the bot's support server invite.
|
CommandClientBuilder |
setStatus(net.dv8tion.jda.core.OnlineStatus status)
Sets the
OnlineStatus the bot will use once Ready
This defaults to ONLINE |
CommandClientBuilder |
useDefaultGame()
Sets the
Game the bot will use as the default:
'Playing Type [prefix]help' |
CommandClientBuilder |
useHelpBuilder(boolean useHelp)
Sets whether the
CommandClient will use
the builder to automatically create a help command or not. |
public CommandClient build()
CommandClientImpl
with the provided settings.
CommandListener
,
and Command
s can be changed.public CommandClientBuilder setOwnerId(java.lang.String ownerId)
ownerId
- The ID of the owner.public CommandClientBuilder setCoOwnerIds(java.lang.String... coOwnerIds)
coOwnerIds
- The ID(s) of the CoOwnerspublic CommandClientBuilder setPrefix(java.lang.String prefix)
prefix
- The prefix for the bot to usepublic CommandClientBuilder setAlternativePrefix(java.lang.String prefix)
prefix
- The alternative prefix for the bot to usepublic CommandClientBuilder useHelpBuilder(boolean useHelp)
CommandClient
will use
the builder to automatically create a help command or not.useHelp
- false
to disable the help command builder, otherwise the CommandClient
will use either the default or one provided via setHelpConsumer(Consumer)
}.public CommandClientBuilder setHelpConsumer(java.util.function.Consumer<CommandEvent> helpConsumer)
null
or not setting this at all will cause the bot to use
the default help builder.helpConsumer
- A consumer to accept a CommandEvent
when a help command is called.public CommandClientBuilder setHelpWord(java.lang.String helpWord)
null
or not setting this at all will set the help word
to "help"
.helpWord
- The word to trigger the help commandpublic CommandClientBuilder setServerInvite(java.lang.String serverInvite)
serverInvite
- The support server invitepublic CommandClientBuilder setEmojis(java.lang.String success, java.lang.String warning, java.lang.String error)
success
- Emoji for successwarning
- Emoji for warningerror
- Emoji for failurepublic CommandClientBuilder setGame(net.dv8tion.jda.core.entities.Game game)
Game
to use when the bot is ready.
null
for no game.game
- The Game to use when the bot is readypublic CommandClientBuilder useDefaultGame()
Game
the bot will use as the default:
'Playing Type [prefix]help'public CommandClientBuilder setStatus(net.dv8tion.jda.core.OnlineStatus status)
OnlineStatus
the bot will use once Ready
This defaults to ONLINEstatus
- The status to setpublic CommandClientBuilder addCommand(Command command)
Command
and registers it to the
CommandClientImpl
for this session.command
- The command to addpublic CommandClientBuilder addCommands(Command... commands)
Command
s to the
CommandClientImpl
for this session.
addCommand(Command)
multiple times.commands
- The Commands to addpublic CommandClientBuilder addAnnotatedModule(java.lang.Object module)
CommandClientImpl
for this session.
For more information on annotated command modules, see
the annotation package
documentation.
module
- The annotated command module to addAnnotatedModuleCompiler
,
JDACommand
public CommandClientBuilder addAnnotatedModules(java.lang.Object... modules)
CommandClientImpl
for this session.
addAnnotatedModule(Object)
multiple times.
For more information on annotated command modules, see
the annotation package
documentation.
modules
- The annotated command modules to addAnnotatedModuleCompiler
,
JDACommand
public CommandClientBuilder setAnnotatedCompiler(AnnotatedModuleCompiler compiler)
AnnotatedModuleCompiler
for this CommandClientBuilder.
If not set this will be the default implementation found here
.
compiler
- The AnnotatedModuleCompiler to useAnnotatedModuleCompiler
,
JDACommand
public CommandClientBuilder setCarbonitexKey(java.lang.String key)
When set, the CommandClientImpl
will automatically update it's Carbonitex listing with relevant information such as server count.
key
- A Carbonitex keypublic CommandClientBuilder setDiscordBotsKey(java.lang.String key)
When set, the CommandClientImpl
will automatically update it's Discord Bots listing with relevant information such as server count.
key
- A Discord Bots API keypublic CommandClientBuilder setDiscordBotListKey(java.lang.String key)
When set, the CommandClientImpl
will automatically update it's Discord Bot List listing with relevant information such as server count.
key
- A Discord Bot List API keypublic CommandClientBuilder setListener(CommandListener listener)
CommandListener
for the
CommandClientImpl
.listener
- The CommandListener for the CommandClientImplpublic CommandClientBuilder setScheduleExecutor(java.util.concurrent.ScheduledExecutorService executor)
ScheduledExecutorService
for the
CommandClientImpl
.executor
- The ScheduledExecutorService for the CommandClientImplpublic CommandClientBuilder setLinkedCacheSize(int linkedCacheSize)
FixedSizeCache
used for caching and pairing the bot's response Message
s with
the calling Message's ID.
Higher cache size means that decay of cache contents will most likely occur later, allowing the deletion of responses when the call is deleted to last for a longer duration. However this also means larger memory usage.
Setting 0
or negative will cause the client to not use linked caching at all.
linkedCacheSize
- The maximum number of paired responses that can be cached, or <1
if the
built CommandClient
will not use linked caching.public CommandClientBuilder setGuildSettingsManager(GuildSettingsManager manager)
GuildSettingsManager
for the CommandClientImpl built using this builder.manager
- The GuildSettingsManager to set.