Class GetBotAction
- java.lang.Object
-
- org.botblock.javabotblockapi.requests.GetBotAction
-
public class GetBotAction extends Object
Class used to perform GET actions on the/api/bots/:id
endpoint.GET requests are cached for 2 minutes unless disabled through either
GetBotAction(true, String)
orGetBotAction(true, String, String)
.- Since:
- 5.0.0
-
-
Constructor Summary
Constructors Constructor Description GetBotAction(boolean disableCache, String id)
Constructor to get an instance of GetBotAction.GetBotAction(boolean disableCache, String userAgent, String id)
Constructor to get the instance of GetBotAction.GetBotAction(String id)
Constructor to get an instance of GetBotAction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JSONObject
getBotInfo(long id)
Gets the full information of a bot.JSONObject
getBotInfo(String id)
Gets the full information of a bot.JSONObject
getBotListInfo(long id)
Gets the information from the various bot lists.JSONArray
getBotListInfo(Long id, String site)
Gets the information from the specified bot list.JSONArray
getBotListInfo(Long id, Site site)
Gets the information from the specified bot list.JSONObject
getBotListInfo(String id)
Gets the information from the various bot lists.JSONArray
getBotListInfo(String id, String site)
Gets the information from the specified bot list.JSONArray
getBotListInfo(String id, Site site)
Gets the information from the specified bot list.String
getDiscriminator(Long id)
Gets the discriminator (The 4 numbers after the # in the username) of the bot.String
getDiscriminator(String id)
Gets the discriminator (The 4 numbers after the # in the username) of the bot.String
getGitHub(Long id)
Gets the GitHub link of the bot.String
getGitHub(String id)
Gets the GitHub link of the bot.String
getLibrary(Long id)
Gets the currently used library of the bot.String
getLibrary(String id)
Gets the currently used library of the bot.String
getName(Long id)
Gets the name of the bot.String
getName(String id)
Gets the name of the bot.String
getOAuthInvite(Long id)
Gets the OAuth invite link of a bot.String
getOAuthInvite(String id)
Gets the OAuth invite link of a bot.List<String>
getOwners(Long id)
Gets an ArrayList with the owner ids of the bot.List<String>
getOwners(String id)
Gets an ArrayList with the owner ids of the bot.String
getPrefix(Long id)
Gets the prefix of the bot.String
getPrefix(String id)
Gets the prefix of the bot.Integer
getServerCount(Long id)
Gets the server count of the bot.Integer
getServerCount(String id)
Gets the server count of the bot.String
getSupportLink(Long id)
Gets the support link (i.e.String
getSupportLink(String id)
Gets the support link (i.e.String
getWebsite(Long id)
Gets the website of the bot.String
getWebsite(String id)
Gets the website of the bot.
-
-
-
Constructor Detail
-
GetBotAction
public GetBotAction(@Nonnull String id)
Constructor to get an instance of GetBotAction.Using this constructor will set the following default values (
{id}
will be replaced with the provided ID):- Cache:
Enabled
- 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:
id
- The id of the bot. This is required for the internal User-Agent.
- Cache:
-
GetBotAction
public GetBotAction(boolean disableCache, @Nonnull String id)
Constructor to get an instance of GetBotAction.
This constructor allows you to disable the internal caching, by providingtrue
as the first argument.Using this constructor will set the following default values (
{id}
will be replaced with the provided ID):- 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.true
means the cache is disabled.id
- The id of the bot. This is required for the internal User-Agent.
- User-Agent:
-
GetBotAction
public GetBotAction(boolean disableCache, @Nonnull String userAgent, @Nonnull String id)
Constructor to get the instance of GetBotAction.
This constructor allows you to disable the internal caching, by providingtrue
as 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.true
means 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
-
getBotInfo
@Nullable public JSONObject getBotInfo(long id)
Gets the full information of a bot. An example of how the returned JSON may look like can be found here:
https://gist.github.com/Andre601/b18b1c4e88e9a405806ce7b6c29a0136Following 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 of the bot to get the information from.- Returns:
- Possibly-null
JSONObject
containing the full information of the bot.
-
getBotInfo
@Nullable public JSONObject getBotInfo(@Nonnull String id)
Gets the full information of a bot. An example of how the returned JSON may look like can be found here:
https://gist.github.com/Andre601/b18b1c4e88e9a405806ce7b6c29a0136Following 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.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the information from.- Returns:
- Possibly-null
JSONObject
containing the full information of the bot.
-
getBotListInfo
@Nullable public JSONObject getBotListInfo(long id)
Gets the information from the various bot lists.
The returned data is entirely dependant on the bot list itself and is therefore unique.Following Exceptions can be thrown from the HTTP request:
IOException
- When the request was non-successful.RatelimitedException
- When the request got rate limited.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The bots id to use.- Returns:
- Possibly-null
JSONObject
containing information from the different bot list.
-
getBotListInfo
@Nullable public JSONObject getBotListInfo(@Nonnull String id)
Gets the information from the various bot lists.
The returned data is entirely dependant on the bot list itself and is therefore unique.Following Exceptions can be thrown from the HTTP request:
IOException
- When the request was non-successful.RatelimitedException
- When the request got rate limited.
RatelimitedException
may be thrown from the RequestHandler, if the HTTP request was rate limited.This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the bot list info from.- Returns:
- Possibly-null
JSONObject
containing information from the different bot list.
-
getBotListInfo
@Nullable public JSONArray getBotListInfo(@Nonnull Long id, @Nonnull Site site)
Gets the information from the specified bot list.
The returned data is entirely dependant on the bot list itself and is therefore unique.Following Exceptions can be thrown from the CheckUtil:
IllegalStateException
- When the provided Site does not 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.
This method may also return
null
if the request wasn't successful.
-
getBotListInfo
@Nullable public JSONArray getBotListInfo(@Nonnull Long id, @Nonnull String site)
Gets the information from the specified bot list.
The returned data is entirely dependant on the bot list itself and is therefore unique.Following Exceptions can be thrown from the CheckUtil:
NullPointerException
- When the provided 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.
This method may also return
null
if the request wasn't successful.
-
getBotListInfo
@Nullable public JSONArray getBotListInfo(@Nonnull String id, @Nonnull Site site)
Gets the information from the specified bot list.
The returned data is entirely dependant on the bot list itself and is therefore unique.Following Exceptions can be thrown from the CheckUtil:
NullPointerException
- When the provided id is empty.IllegalStateException
- When the provided Site does not 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.
This method may also return
null
if the request wasn't successful.
-
getBotListInfo
@Nullable public JSONArray getBotListInfo(@Nonnull String id, @Nonnull String site)
Gets the information from the specified bot list.
The returned data is entirely dependant on the bot list itself and is therefore unique.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.
This method may also return
null
if the request wasn't successful.
-
getDiscriminator
@Nullable public String getDiscriminator(@Nonnull Long id)
Gets the discriminator (The 4 numbers after the # in the username) of the bot.
The discriminator is based on the most common appearance of it across the bot lists.Following Exceptions can be thrown from the HTTP request:
IOException
- When the request was non-successful.RatelimitedException
- When the request got rate limited.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the discriminator from.- Returns:
- Possibly-null String containing the discriminator of the bot or
0000
if the provided id is invalid. - Since:
- 4.2.0
-
getDiscriminator
@Nullable public String getDiscriminator(@Nonnull String id)
Gets the discriminator (The 4 numbers after the # in the username) of the bot.
The discriminator is based on the most common appearance of it.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.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the discriminator from.- Returns:
- Possibly-null String containing the discriminator of the bot or
0000
if the provided id is invalid. - Since:
- 4.2.0
-
getGitHub
@Nullable public String getGitHub(@Nonnull Long id)
Gets the GitHub link of the bot.
The GitHub link is based on the most common appearance of it.Following Exceptions can be thrown from the HTTP request:
IOException
- When the request was non-successful.RatelimitedException
- When the request got rate limited.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the GitHub link from.- Returns:
- Possibly-null or possibly-empty String containing the GitHub link of the bot.
- Since:
- 4.2.0
-
getGitHub
@Nullable public String getGitHub(@Nonnull String id)
Gets the GitHub link of the bot.
The GitHub link is based on the most common appearance of it.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.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the GitHub link from.- Returns:
- Possibly-null or possibly-empty String containing the GitHub link of the bot.
- Since:
- 4.2.0
-
getLibrary
@Nullable public String getLibrary(@Nonnull Long id)
Gets the currently used library of the bot.
The library is based on the most common appearance of it.Following Exceptions can be thrown from the HTTP request:
IOException
- When the request was non-successful.RatelimitedException
- When the request got rate limited.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the library from.- Returns:
- Possibly-null or possibly-empty String containing the library of the bot.
- Since:
- 4.2.0
-
getLibrary
@Nullable public String getLibrary(@Nonnull String id)
Gets the currently used library of the bot.
The library is based on the most common appearance of it.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.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the library from.- Returns:
- Possibly-null or possibly-empty String containing the library of the bot.
- Since:
- 4.2.0
-
getName
@Nullable public String getName(@Nonnull Long id)
Gets the name of the bot.
The name is based on the most common appearance of it.Following Exceptions can be thrown from the HTTP request:
IOException
- When the request was non-successful.RatelimitedException
- When the request got rate limited.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the name from.- Returns:
- Possibly-null String containing the name of the bot or
Unknown
if the provided id is invalid. - Since:
- 4.2.0
-
getName
@Nullable public String getName(@Nonnull String id)
Gets the name of the bot.
The name is based on the most common appearance of it.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.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the name from.- Returns:
- Possibly-null String containing the name of the bot or
Unknown
if the provided id is invalid. - Since:
- 4.2.0
-
getOAuthInvite
@Nullable public String getOAuthInvite(@Nonnull Long id)
Gets the OAuth invite link of a bot.
The OAuth invite is used to add a bot to a Discord server.Following Exceptions can be thrown from the HTTP request:
IOException
- When the request was non-successful.RatelimitedException
- When the request got rate limited.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the OAuth link from.- Returns:
- Possibly-null or possibly-empty String containing the OAuth link for the bot.
- Since:
- 5.1.13
-
getOAuthInvite
@Nullable public String getOAuthInvite(@Nonnull String id)
Gets the OAuth invite link of a bot.
The OAuth invite is used to add a bot to a Discord server.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.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the OAuth link from.- Returns:
- Possibly-null or possibly-empty String containing the OAuth link for the bot.
- Since:
- 5.1.13
-
getOwners
@Nullable public List<String> getOwners(@Nonnull Long id)
Gets an ArrayList with the owner ids of the bot.
The IDs listed are based on how often they appear on the different bot lists.Following Exceptions can be thrown from the HTTP request:
IOException
- When the request was non-successful.RatelimitedException
- When the request got rate limited.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the Owners from.- Returns:
- Possibly-empty ArrayList containing the owners of the bot.
-
getOwners
@Nullable public List<String> getOwners(@Nonnull String id)
Gets an ArrayList with the owner ids of the bot.
The IDs listed are based on how often they appear on the different 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.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the Owners from.- Returns:
- Possibly-empty ArrayList containing the owners of the bot.
-
getPrefix
@Nullable public String getPrefix(@Nonnull Long id)
Gets the prefix of the bot.
The prefix is based on the most common appearance of it.Following Exceptions can be thrown from the HTTP request:
IOException
- When the request was non-successful.RatelimitedException
- When the request got rate limited.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the prefix from.- Returns:
- Possibly-null or possibly-empty String containing the prefix of the bot.
- Since:
- 4.2.0
-
getPrefix
@Nullable public String getPrefix(@Nonnull String id)
Gets the prefix of the bot.
The prefix is based on the most common appearance of it.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.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the prefix from.- Returns:
- Possibly-null or possibly-empty String containing the prefix of the bot.
- Since:
- v4.2.0
-
getServerCount
@Nullable public Integer getServerCount(@Nonnull Long id)
Gets the server count of the bot.
The server count is based on the most common appearance of it.Following Exceptions can be thrown from the HTTP request:
IOException
- When the request was non-successful.RatelimitedException
- When the request got rate limited.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the server count from.- Returns:
- Possibly-null Integer containing the server count for the bot.
-
getServerCount
@Nullable public Integer getServerCount(@Nonnull String id)
Gets the server count of the bot.
The server count is based on the most common appearance of it.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.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the server count from.- Returns:
- Possibly-null Integer containing the server count for the bot.
-
getSupportLink
@Nullable public String getSupportLink(@Nonnull Long id)
Gets the support link (i.e. Discord invite) from the bot.
The link is based on the most common appearance of it.Following Exceptions can be thrown from the HTTP request:
IOException
- When the request was non-successful.RatelimitedException
- When the request got rate limited.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the support link from.- Returns:
- Possibly-null or possibly-empty String containing the support link.
-
getSupportLink
@Nullable public String getSupportLink(@Nonnull String id)
Gets the support link (i.e. Discord invite) from the bot.
The link is based on the most common appearance of it.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.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the support link from.- Returns:
- Possibly-null or possibly-empty String containing the support link.
-
getWebsite
@Nullable public String getWebsite(@Nonnull Long id)
Gets the website of the bot.
The website is based on the most common appearance of it.Following Exceptions can be thrown from the HTTP request:
IOException
- When the request was non-successful.RatelimitedException
- When the request got rate limited.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the website from.- Returns:
- Possibly-null or possibly-empty String containing the bot's website.
- Since:
- v4.2.0
-
getWebsite
@Nullable public String getWebsite(@Nonnull String id)
Gets the website of the bot.
The website is based on the most common appearance of it.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.
This method may also return
null
if the request wasn't successful.- Parameters:
id
- The id of the bot to get the website from.- Returns:
- Possibly-null or possibly-empty String containing the bot's website.
- Since:
- v4.2.0
-
-