Class GetListAction
- java.lang.Object
-
- org.botblock.javabotblockapi.requests.GetListAction
-
public class GetListAction extends Object
Class used to perform GET actions on the/api/listsand/api/lists/:idendpoints.GET requests are cached for 2 minutes unless disabled through
GetListAction(true, String)orGetListAction(true, String, String).- Since:
- 5.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGetListAction.ApiFieldEnum containing the different API fields a bot list may have.
-
Constructor Summary
Constructors Constructor Description GetListAction(boolean disableCache, String id)Constructor to get an instance of GetListAction.GetListAction(boolean disableCache, String userAgent, String id)Constructor to get the instance of GetListAction.GetListAction(String id)Constructor to get an instance of GetListAction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetApiField(String id, String site, GetListAction.ApiField field)Gets the name of the specified field.StringgetApiField(String id, Site site, GetListAction.ApiField field)Gets the name of the specified field.StringgetBotWidgetUrl(String id, String site)Gets the URL used to display a widget (custom image) of the bot.StringgetBotWidgetUrl(String id, Site site)Gets the URL used to display a widget (custom image) of the bot.StringgetDescription(String id, String site)Gets the description of the bot list.StringgetDescription(String id, Site site)Gets the description of the bot list.StringgetDiscordInvite(String id, String site)Gets the invite to the Discord of the bot list.StringgetDiscordInvite(String id, Site site)Gets the invite to the Discord of the bot list.JSONArraygetFeatures(String id, String site)Gets the features of the bot list.JSONArraygetFeatures(String id, Site site)Gets the features of the bot list.JSONObjectgetFilteredLists(String id)Returns the filtered JSON of bot lists.StringgetIcon(String id, String site)Gets the URL displaying the current Icon of the bot list.StringgetIcon(String id, Site site)Gets the URL displaying the current Icon of the bot list.StringgetId(String id, String site)Gets the id of the bot list.StringgetId(String id, Site site)Gets the id of the bot list.StringgetLanguage(String id, String site)Gets the primary language of the bot list.StringgetLanguage(String id, Site site)Gets the primary language of the bot list.JSONObjectgetList(String id, String site)Gets the information of a specific bot list.JSONObjectgetList(String id, Site site)Gets the information of a specific bot list.JSONObjectgetLists(String id)Gets the information about all the currently listed bot lists.StringgetName(String id, String site)Gets the name of the bot list.StringgetName(String id, Site site)Gets the name of the bot list.StringgetOwners(String id, String site)Gets the owners of a bot list.StringgetOwners(String id, Site site)Gets the owners of a bot list.IntegergetTimeAdded(String id, String site)Gets the UNIX timestamp of when the bot list was added to BotBlock as Integer.IntegergetTimeAdded(String id, Site site)Gets the UNIX timestamp of when the bot list was added to BotBlock as Integer.StringgetUrl(String id, String site)Gets the URL for the bot list's website.StringgetUrl(String id, Site site)Gets the URL for the bot list's website.booleanisDefunct(String id, String site)Returns if the bot list is defunct.booleanisDefunct(String id, Site site)Returns if the bot list is defunct.booleanisDiscordOnly(String id, String site)Returns if the bot list is only for Discord bots.booleanisDiscordOnly(String id, Site site)Returns if the bot list is only for Discord bots.
-
-
-
Constructor Detail
-
GetListAction
public GetListAction(@Nonnull String id)
Constructor to get an instance of GetListAction.Using this constructor will set the following default values:
- Cache:
Enabled - 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.
- Cache:
-
GetListAction
public GetListAction(boolean disableCache, @Nonnull String id)Constructor to get an instance of GetListAction.
This constructor allows you to disable the internal caching, by providingtrueas the first argument.Using this constructor will set the following default values:
- User-Agent:
"JavaBotBlockAPI-0000/API_VERSION (Unknown; +https://jbba.dev) DBots/{id}"
Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.
- Parameters:
disableCache- If the cache should be disabled.truemeans the cache is disabled.id- The id of the bot. This is required for the internal User-Agent.
- User-Agent:
-
GetListAction
public GetListAction(boolean disableCache, @Nonnull String userAgent, @Nonnull String id)Constructor to get the instance of GetListAction.
This constructor allows you to disable the internal caching, by providingtrueas the first argument and also set a own User-Agent for the requests by providing any String as the second argument.Note that you can provide
{id}inside the userAgent to get it replaced with the provided id.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided userAgent or id is empty.
- Parameters:
disableCache- If the cache should be disabled.truemeans the cache is disabled.userAgent- The Name that should be used as User-Agent.id- The id of the bot. This is required for the internal User-Agent.
-
-
Method Detail
-
getApiField
@Nullable public String getApiField(@Nonnull String id, @Nonnull Site site, @Nonnull GetListAction.ApiField field)
Gets the name of the specified field. The returned String can either be a URL or a field name.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
-
getApiField
@Nullable public String getApiField(@Nonnull String id, @Nonnull String site, @Nonnull GetListAction.ApiField field)
Gets the name of the specified field. The returned String can either be a URL or a field name.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
-
getBotWidgetUrl
@Nullable public String getBotWidgetUrl(@Nonnull String id, @Nonnull Site site)
Gets the URL used to display a widget (custom image) of the bot.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- Possibly-null String containing the URL used to display a widget.
-
getBotWidgetUrl
@Nullable public String getBotWidgetUrl(@Nonnull String id, @Nonnull String site)
Gets the URL used to display a widget (custom image) of the bot.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- Possibly-null String containing the URL used to display a widget.
-
getDescription
@Nullable public String getDescription(@Nonnull String id, @Nonnull Site site)
Gets the description of the bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- Possibly-null String containing the description/tag line of the bot list.
-
getDescription
@Nullable public String getDescription(@Nonnull String id, @Nonnull String site)
Gets the description of the bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- Possibly-null String containing the description/tag line of the bot list.
-
getDiscordInvite
@Nullable public String getDiscordInvite(@Nonnull String id, @Nonnull Site site)
Gets the invite to the Discord of the bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- Possibly-null String containing the invite to the Discord of the bot list.
-
getDiscordInvite
@Nullable public String getDiscordInvite(@Nonnull String id, @Nonnull String site)
Gets the invite to the Discord of the bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- Possibly-null String containing the invite to the Discord of the bot list.
-
getFeatures
public JSONArray getFeatures(@Nonnull String id, @Nonnull Site site)
Gets the features of the bot list.
The listed features can be both positive and negative.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
-
getFeatures
public JSONArray getFeatures(@Nonnull String id, @Nonnull String site)
Gets the features of the bot list.
The listed features can be both positive and negative.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
-
getFilteredLists
public JSONObject getFilteredLists(@Nonnull String id)
Returns the filtered JSON of bot lists.
The filtered version only contains theAPI fieldsof the bot lists.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.- Returns:
JSONObjectcontaining the filtered information of the bot lists.
-
getIcon
@Nullable public String getIcon(@Nonnull String id, @Nonnull Site site)
Gets the URL displaying the current Icon of the bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- Possibly-null String containing the Icon-URL of the bot list.
-
getIcon
@Nullable public String getIcon(@Nonnull String id, @Nonnull String site)
Gets the URL displaying the current Icon of the bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- Possibly-null String containing the Icon-URL of the bot list.
-
getId
public String getId(@Nonnull String id, @Nonnull Site site)
Gets the id of the bot list.
The id is used for the/api/countendpoint.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- String containing the id of the bot list.
-
getId
public String getId(@Nonnull String id, @Nonnull String site)
Gets the id of the bot list.
The id is used for the/api/countendpoint.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- String containing the id of the bot list.
-
getLanguage
public String getLanguage(@Nonnull String id, @Nonnull Site site)
Gets the primary language of the bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- String containing the primarily used language of the bot list.
-
getLanguage
public String getLanguage(@Nonnull String id, @Nonnull String site)
Gets the primary language of the bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- String containing the primarily used language of the bot list.
-
getList
public JSONObject getList(@Nonnull String id, @Nonnull Site site)
Gets the information of a specific bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
JSONObjectcontaining information about the specified bot list.
-
getList
public JSONObject getList(@Nonnull String id, @Nonnull String site)
Gets the information of a specific bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
JSONObjectcontaining information about the specified bot list.
-
getLists
public JSONObject getLists(@Nonnull String id)
Gets the information about all the currently listed bot lists.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.- Returns:
JSONObjectcontaining information about all the different bot lists.
-
getName
public String getName(@Nonnull String id, @Nonnull Site site)
Gets the name of the bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- String containing the name of the bot list.
-
getName
public String getName(@Nonnull String id, @Nonnull String site)
Gets the name of the bot list.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- String containing the name of the bot list.
-
getOwners
@Nullable public String getOwners(@Nonnull String id, @Nonnull Site site)
Gets the owners of a bot list.
The pattern in which the owners are listed is<name#discrim> (<id>), <name#discrim> (<id>), ...Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- Possibly-null String containing the owners of the bot list.
-
getOwners
@Nullable public String getOwners(@Nonnull String id, @Nonnull String site)
Gets the owners of a bot list.
The pattern in which the owners are listed is<name#discrim> (<id>), <name#discrim> (<id>), ...Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- Possibly-null String containing the owners of the bot list,
-
getTimeAdded
public Integer getTimeAdded(@Nonnull String id, @Nonnull Site site)
Gets the UNIX timestamp of when the bot list was added to BotBlock as Integer.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- Integer displaying the UNIX time at which the bot list was added to BotBlock.
-
getTimeAdded
public Integer getTimeAdded(@Nonnull String id, @Nonnull String site)
Gets the UNIX timestamp of when the bot list was added to BotBlock as Integer.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- Integer displaying the UNIX time at which the bot list was added to BotBlock.
-
getUrl
public String getUrl(@Nonnull String id, @Nonnull Site site)
Gets the URL for the bot list's website.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- String containing the URL to the bot list website.
-
getUrl
public String getUrl(@Nonnull String id, @Nonnull String site)
Gets the URL for the bot list's website.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
- String containing the URL to the bot list website.
-
isDefunct
public boolean isDefunct(@Nonnull String id, @Nonnull Site site)
Returns if the bot list is defunct.
A defunct bot list is not displayed on the main site and is also excluded from the POST api.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
trueif the bot list is defunct,falseotherwise.
-
isDefunct
public boolean isDefunct(@Nonnull String id, @Nonnull String site)
Returns if the bot list is defunct.
A defunct bot list is not displayed on the main site and is also excluded from the POST api.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
trueif the bot list is defunct,falseotherwise.
-
isDiscordOnly
public boolean isDiscordOnly(@Nonnull String id, @Nonnull Site site)
Returns if the bot list is only for Discord bots.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id is empty.IllegalStateException- When the provided Site doesn't support GET requests.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
trueif the list is only for Discord bots,falseotherwise.
-
isDiscordOnly
public boolean isDiscordOnly(@Nonnull String id, @Nonnull String site)
Returns if the bot list is only for Discord bots.Following Exceptions can be thrown from the CheckUtil:
NullPointerException- When the provided id or site is empty.
Following Exceptions can be thrown from the HTTP request:
IOException- When the request was non-successful.RatelimitedException- When the request got rate limited.
- Parameters:
id- The id used for the cache.site- Thesiteto get information from.- Returns:
trueif the list is only for Discord bots,falseotherwise.
-
-