Package org.botblock.javabotblockapi.requests

## Class PostAction

- java.lang.Object
- - org.botblock.javabotblockapi.requests.PostAction

-     public class PostAction
      extends Object

  Class used to perform POST requests towards the `/api/count` endpoint.

  You can `post automatically` or `post manually`.

  Since:
    3.0.0

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `PostAction​(String id)` | Constructor to get an instance of PostAction.
    `PostAction​(String userAgent, String id)` | Constructor to get an instance of PostAction.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `disableAutoPost()` | Shuts down the scheduler, to stop the automatic posting.
    `void` | `enableAutoPost​(Long botId, int guilds, BotBlockAPI botBlockAPI)` | Starts posting of the guild count each n minutes.
    `void` | `enableAutoPost​(String botId, int guilds, BotBlockAPI botBlockAPI)` | Starts posting of the guild count each n minutes.
    `void` | `enableAutoPost​(JDA jda, BotBlockAPI botBlockAPI)` | Starts posting of the guild count each n minutes.
    `void` | `enableAutoPost​(ShardManager shardManager, BotBlockAPI botBlockAPI)` | Starts posting of the guild count each n minutes.
    `void` | `postGuilds​(Long botId, Integer guilds, BotBlockAPI botBlockAPI)` | Posts the guild count with the provided bot id.
    `void` | `postGuilds​(String botId, Integer guilds, BotBlockAPI botBlockAPI)` | Posts the guild count with the provided bot id.
    `void` | `postGuilds​(JDA jda, BotBlockAPI botBlockAPI)` | Posts the guild count provided through the `JDA instance`.
    `void` | `postGuilds​(ShardManager shardManager, BotBlockAPI botBlockAPI)` | Posts the guild count from the provided `ShardManager instance`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PostAction

          public PostAction​(@Nonnull
                            String id)

      Constructor to get an instance of PostAction.

      Using this constructor will set the following default values:

      - User-Agent: `"JavaBotBlockAPI-0000/API_VERSION (Unknown; +https://jbba.dev) DBots/{id}"`
      Parameters:
        `id` - The id of the bot. This is required for the internal User-Agent.
      Throws:
        `NullPointerException` - When the provided id is empty.

    - #### PostAction

          public PostAction​(@Nonnull
                            String userAgent,
                            @Nonnull
                            String id)

      Constructor to get an instance of PostAction.
      This constructor allows you to set a own User-Agent by providing any String as the first argument.

      Note that you can provide `{id}` inside the userAgent to get it replaced with the provided id.

      Parameters:
        `userAgent` - The Name to use as User-Agent.
        `id` - The id of the bot. This is required for the internal User-Agent.
      Throws:
        `NullPointerException` - When the provided userAgent or id is empty.

  - ### Method Detail

    - #### disableAutoPost

          public void disableAutoPost()

      Shuts down the scheduler, to stop the automatic posting.

    - #### enableAutoPost

          public void enableAutoPost​(@Nonnull
                                     JDA jda,
                                     @Nonnull
                                     BotBlockAPI botBlockAPI)

      Starts posting of the guild count each n minutes.
      The delay in which this happens is set using ``BotBlockAPI.Builder#setUpdateInterval(Integer)``

      The scheduler will stop (cancel) the task, when an Exception appears!

      Parameters:
        `jda` - The `JDA instance` to use.
        `botBlockAPI` - The `BotBlockAPI instance` to use.

    - #### enableAutoPost

          public void enableAutoPost​(@Nonnull
                                     Long botId,
                                     int guilds,
                                     @Nonnull
                                     BotBlockAPI botBlockAPI)

      Starts posting of the guild count each n minutes.
      The delay in which this happens is set using ``BotBlockAPI.Builder.setUpdateDelay(Integer)` BotBlockAPI.Builder#setUpdateInterval(Integer)}`

      The scheduler will stop (cancel) the task, when an Exception appears!

      Parameters:
        `botId` - The ID of the bot as Long.
        `guilds` - The guild count.
        `botBlockAPI` - The `BotBlockAPI instance` to use.

    - #### enableAutoPost

          public void enableAutoPost​(@Nonnull
                                     ShardManager shardManager,
                                     @Nonnull
                                     BotBlockAPI botBlockAPI)

      Starts posting of the guild count each n minutes.
      The delay in which this happens is set using ``BotBlockAPI.Builder.setUpdateDelay(Integer)` BotBlockAPI.Builder#setUpdateInterval(Integer)}`

      The scheduler will stop (cancel) the task, when an Exception appears!

      Parameters:
        `shardManager` - The `ShardManager instance` to use.
        `botBlockAPI` - The `BotBlockAPI instance` to use.

    - #### enableAutoPost

          public void enableAutoPost​(@Nonnull
                                     String botId,
                                     int guilds,
                                     @Nonnull
                                     BotBlockAPI botBlockAPI)

      Starts posting of the guild count each n minutes.
      The delay in which this happens is set using ``BotBlockAPI.Builder.setUpdateDelay(Integer)` BotBlockAPI.Builder#setUpdateInterval(Integer)}`

      The scheduler will stop (cancel) the task, when an Exception appears!

      Parameters:
        `botId` - The ID of the bot as String.
        `guilds` - The guild count.
        `botBlockAPI` - The `BotBlockAPI instance` to use.

    - #### postGuilds

          public void postGuilds​(@Nonnull
                                 JDA jda,
                                 @Nonnull
                                 BotBlockAPI botBlockAPI)
                          throws IOException,
                                 RatelimitedException

      Posts the guild count provided through the `JDA instance`.
      It's recommended to use `postGuilds(ShardManager, BotBlockAPI)` if you're using a sharded bot.

      When the amount of shards a bot has is bigger than one will `shard_id` and `shard_count` be added.

      Parameters:
        `jda` - The `JDA instance`.
        `botBlockAPI` - The `BotBlockAPI instance`.
      Throws:
        `IOException` - When the post request couldn't be performed.
        `RatelimitedException` - When we exceed the rate-limit of the BotBlock API.

    - #### postGuilds

          public void postGuilds​(@Nonnull
                                 Long botId,
                                 @Nonnull
                                 Integer guilds,
                                 @Nonnull
                                 BotBlockAPI botBlockAPI)
                          throws IOException,
                                 RatelimitedException

      Posts the guild count with the provided bot id.
      Parameters:
        `botId` - The ID of the bot.
        `guilds` - The guild count.
        `botBlockAPI` - The `BotBlockAPI instance`.
      Throws:
        `IOException` - When the post request couldn't be performed.
        `RatelimitedException` - When we exceed the rate-limit of the BotBlock API.

    - #### postGuilds

          public void postGuilds​(@Nonnull
                                 ShardManager shardManager,
                                 @Nonnull
                                 BotBlockAPI botBlockAPI)
                          throws IOException,
                                 RatelimitedException

      Posts the guild count from the provided `ShardManager instance`.
      The guild count of each shard will be added as an JSONArray.
      Parameters:
        `shardManager` - The `ShardManager instance`.
        `botBlockAPI` - The `BotBlockAPI instance`.
      Throws:
        `IOException` - When the post request couldn't be performed.
        `RatelimitedException` - When we exceed the rate-limit of the BotBlock API.

    - #### postGuilds

          public void postGuilds​(@Nonnull
                                 String botId,
                                 @Nonnull
                                 Integer guilds,
                                 @Nonnull
                                 BotBlockAPI botBlockAPI)
                          throws IOException,
                                 RatelimitedException

      Posts the guild count with the provided bot id.
      Parameters:
        `botId` - The ID of the bot.
        `guilds` - The guild count.
        `botBlockAPI` - The `BotBlockAPI instance`.
      Throws:
        `IOException` - When the post request couldn't be performed.
        `RatelimitedException` - When we exceed the rate-limit of the BotBlock API.