Class BotBuilder

java.lang.Object
io.github.unknowncoder56.javaslc.BotBuilder

public class BotBuilder extends Object
A builder class to build a Bot instance.
  • Method Details

    • newInstance

      public static BotBuilder newInstance()
      Returns a new BotBuilder instance. This method is used for instantiation to enable chaining of method calls.
      Returns:
      A new BotBuilder instance to which method calls are to be chained.
    • setPrefix

      public BotBuilder setPrefix(String prefix)
      Sets the bot prefix.
      Parameters:
      prefix - The bot prefix.
      Returns:
      The BotBuilder instance to facilitate chaining of method calls.
    • setStartListener

      public BotBuilder setStartListener(StartListener startListener)
      Sets the start listener.
      Parameters:
      startListener - The start listener.
      Returns:
      The BotBuilder instance to facilitate chaining of method calls.
      See Also:
    • setErrorListener

      public BotBuilder setErrorListener(ErrorListener errorListener)
      Sets the error listener.
      Parameters:
      errorListener - The error listener.
      Returns:
      The BotBuilder instance to facilitate chaining of method calls.
      See Also:
    • setToken

      public BotBuilder setToken(String token)
      Sets the bot token. It is a confidential value, so it cannot be accessed anymore.
      Parameters:
      token - The bot token.
      Returns:
      The BotBuilder instance to facilitate chaining of method calls.
    • setBotUserId

      public BotBuilder setBotUserId(long botUserId)
      Sets the bot user ID.
      Parameters:
      botUserId - The bot user ID.
      Returns:
      The BotBuilder instance to facilitate chaining of method calls.
    • addMessageListener

      public BotBuilder addMessageListener(MessageListener messageListener)
      Adds a message listener.
      Parameters:
      messageListener - The message listener.
      Returns:
      The BotBuilder instance to facilitate chaining of method calls.
      See Also:
    • addCommandListener

      public BotBuilder addCommandListener(CommandListener commandListener)
      Adds a command listener.
      Parameters:
      commandListener - The command listener.
      Returns:
      The BotBuilder instance to facilitate chaining of method calls.
      See Also:
    • build

      public Bot build()
      Builds the bot and returns a Bot instance constructed with the specified values. Any skipped values are set to default. Skipping the prefix, token, or bot user ID will result in a RuntimeException if not set later in the Bot before running the Bot.run() method.
      Returns:
      A Bot instance constructed with the specified values.