Package io.github.unknowncoder56.javaslc
Class BotBuilder
java.lang.Object
io.github.unknowncoder56.javaslc.BotBuilder
A builder class to build a
Bot instance.-
Method Summary
Modifier and TypeMethodDescriptionaddCommandListener(CommandListener commandListener) Adds a command listener.addMessageListener(MessageListener messageListener) Adds a message listener.build()Builds the bot and returns aBotinstance constructed with the specified values.static BotBuilderReturns a newBotBuilderinstance.setBotUserId(String botUserId) Sets the bot user ID.setErrorListener(ErrorListener errorListener) Sets the error listener.Sets the bot prefix.setStartListener(StartListener startListener) Sets the start listener.Sets the bot token.
-
Method Details
-
newInstance
Returns a newBotBuilderinstance. This method is used for instantiation to enable chaining of method calls.- Returns:
- A new
BotBuilderinstance to which method calls are to be chained.
-
setPrefix
Sets the bot prefix.- Parameters:
prefix- The bot prefix.- Returns:
- The
BotBuilderinstance to facilitate chaining of method calls.
-
setStartListener
Sets the start listener.- Parameters:
startListener- The start listener.- Returns:
- The
BotBuilderinstance to facilitate chaining of method calls. - See Also:
-
setErrorListener
Sets the error listener.- Parameters:
errorListener- The error listener.- Returns:
- The
BotBuilderinstance to facilitate chaining of method calls. - See Also:
-
setToken
Sets the bot token. It is a confidential value, so it cannot be accessed anymore.- Parameters:
token- The bot token.- Returns:
- The
BotBuilderinstance to facilitate chaining of method calls.
-
setBotUserId
Sets the bot user ID.- Parameters:
botUserId- The bot user ID.- Returns:
- The
BotBuilderinstance to facilitate chaining of method calls.
-
addMessageListener
Adds a message listener.- Parameters:
messageListener- The message listener.- Returns:
- The
BotBuilderinstance to facilitate chaining of method calls. - See Also:
-
addCommandListener
Adds a command listener.- Parameters:
commandListener- The command listener.- Returns:
- The
BotBuilderinstance to facilitate chaining of method calls. - See Also:
-
build
Builds the bot and returns aBotinstance constructed with the specified values. Any skipped values are set to default. Skipping the prefix, token, or bot user ID will result in aRuntimeExceptionif not set later in theBotbefore running theBot.run()method.- Returns:
- A
Botinstance constructed with the specified values.
-