Interface IBotLoader


public interface IBotLoader
An interface responsible for the lifecycle management and execution of bot files within the Tori Server environment.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    disableBot(String botName)
    Gracefully shuts down and removes a bot from the active bots list.
    boolean
    enableBot(String jarFileName)
    Dynamically loads and starts a bot from a JAR file at runtime.
    Retrieves a list of all bot instances that are currently running on the server.
    void
    Scans the designated bots directory, reads their metadata, initializes their class loaders, and starts the bots concurrently.
    void
    Gracefully shuts down all currently active bots.
  • Method Details

    • loadBots

      void loadBots() throws Exception
      Scans the designated bots directory, reads their metadata, initializes their class loaders, and starts the bots concurrently.
      Throws:
      Exception - If a critical error occurs during the file reading or class loading process.
    • getActiveBots

      List<JavaDiscordBot> getActiveBots()
      Retrieves a list of all bot instances that are currently running on the server.
      Returns:
      An unmodifiable list of active JavaDiscordBot instances.
    • shutdownAll

      void shutdownAll()
      Gracefully shuts down all currently active bots.

      This method triggers the onShutdown() lifecycle event for each bot, allowing them to safely disconnect their JDA instances and save necessary data.

    • enableBot

      boolean enableBot(String jarFileName)
      Dynamically loads and starts a bot from a JAR file at runtime.

      This method finds the specified JAR file in the bots directory, reads its metadata, initializes its class loader, and starts the bot in a separate thread.

      Parameters:
      jarFileName - The name of the bot JAR file (e.g., "MyBot.jar")
      Returns:
      true if the bot was successfully enabled, false otherwise.
    • disableBot

      boolean disableBot(String botName)
      Gracefully shuts down and removes a bot from the active bots list.

      This method finds the bot by name, calls its onShutdown() lifecycle event, and removes it from the list of active bots.

      Parameters:
      botName - The name of the bot to disable (matches the 'name' field in bot.yml)
      Returns:
      true if the bot was successfully disabled, false if not found.