Skip to content

Commit d31284f

Browse files
committed
Add getAll methods
1 parent 543c6d6 commit d31284f

File tree

3 files changed

+175
-15
lines changed

3 files changed

+175
-15
lines changed

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
[Javadocs]: https://docs.botblock.org/JavaBotBlockAPI/
77

8-
[BadgeDownload]: https://img.shields.io/badge/dynamic/json.svg?label=Bintray&query=name&style=plastic&url=https%3A%2F%2Fapi.bintray.com%2Fpackages%2Fandre601%2Fmaven%2FJavaBotBlockAPI%2Fversions%2F_latest
8+
[BadgeDownload]: https://img.shields.io/bintray/v/andre601/maven/JavaBotBlockAPI?label=Bintray&style=plastic
99
[Download]: https://bintray.com/andre601/maven/JavaBotBlockAPI/_latestVersion
1010

1111
[image]: https://raw.githubusercontent.com/botblock/JavaBotBlockAPI/master/src/main/resources/JavaBotBlockAPI.png
@@ -78,35 +78,35 @@ Remember to use `.build();` at the end to create the class.
7878

7979
### Auto Posting
8080
JavaBotBlockAPI allows you to post the guild counts automatically every X minutes.
81-
To do this, you first need to get an instance of the RequestHandler and then call `.startAutoPosting(...)`.
81+
To do this, you first need to get an instance of the PostAction and then call `.enableAutoPost(...)`.
8282

8383
Here is an example:
8484
```java
85-
RequestHandler handler = new RequestHandler();
85+
PostAction postAction = new PostAction();
8686

8787
// api is the instance of the BotBlockAPI
88-
handler.startAutoPosting(jda, api);
88+
postAction.enableAutoPost(jda, api);
8989
```
9090
The delay in which you post the guild counts is set through the `.setUpdateInterval(int)` method in the BotBlockAPI.Builder().
9191

9292
### Cancel auto posting
93-
To cancel the auto posting just call `.stopAutoPosting();` in the RequestHandler and it should cancel the scheduler.
93+
To cancel the auto posting just call `.disableAutoPost();` in the RequestHandler and it should cancel the scheduler.
9494

9595
### Manually posting
9696
There are methods that allow you to post the guild counts manually.
97-
To Post your guild counts, just call the `.postGuilds(..., ...)` method in the RequestHandler.
97+
To Post your guild counts, just call the `.postGuilds(...)` method in the PostAction.
9898

9999
```java
100-
RequestHandler handler = new RequestHandler();
100+
PostAction postAction = new PostAction();
101101

102102
// api is the instance of the BotBlockAPI
103-
handler.postGuilds(jda, api);
103+
postAction.postGuilds(jda, api);
104104
```
105105

106106
## GET methods
107-
Since version 2.0.0 of JavaBotBlockAPI can you get certain informations of a bot or the available Botlists on the BotBlock API.
107+
Since version 2.0.0 of JavaBotBlockAPI can you get certain information of a bot or the available Bot lists on the BotBlock API.
108108

109-
### All available Botlists
109+
### All available Bot lists
110110
You can call `.getBotlists()` to receive a JSONObject with all available Botlists in the BotBlockAPI.
111111

112112
The returned JSONObject could look like this:
@@ -134,8 +134,8 @@ The returned JSONObject could look like this:
134134
```
135135

136136
### Single Botlist
137-
Calling `.getBotlist(String)` returns a specific Botlist as JSONObject.
138-
For example does `.getBotlist("lbots.org")` return the following JSONObject:
137+
Calling `.getBotlist(..., Site|String)` returns a specific Botlist as JSONObject.
138+
For example does `.getBotlist("123456789012345678", "lbots.org")` return the following JSONObject:
139139
```json
140140
{
141141
"api_docs": "https://lbots.org/api/docs",
@@ -179,7 +179,7 @@ The JSONObject can look like this:
179179
`name`, `owners`, `server_count` and `invite` is based on the most common appearances of the data.
180180

181181
### Botinfo from all Botlists
182-
You can call `.getBotInfos(...)` to only receive the bot info from all the Botlists.
182+
You can call `.getBotListInfo(...)` to only receive the bot info from all the Botlists.
183183

184184
The returned JSONObject can look like this:
185185
```json
@@ -197,7 +197,7 @@ The returned JSONObject can look like this:
197197
`{"data"}` is the JSON that is returned by the provided Botlist meaning it's different for each site.
198198

199199
### Botinfo of a single site
200-
With `.getBotInfo(..., String)` can you receive the info of a specific site.
200+
With `.getBotListInfo(..., Site|String)` can you receive the info of a specific site.
201201
The returned data depends on the selected site and can be different for each one.
202202

203203
### Owners

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies{
2424
api group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.2.2'
2525
api group: 'org.json', name: 'json', version: '20190722'
2626
api group: 'org.jetbrains', name: 'annotations', version: '17.0.0'
27-
api(group: 'net.dv8tion', name: 'JDA', version: '4.0.0_52'){
27+
api(group: 'net.dv8tion', name: 'JDA', version: '4.0.0_55'){
2828
exclude(module: 'opus-java')
2929
}
3030
api group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '2.8.0'

src/main/java/com/andre601/javabotblockapi/requests/GetAction.java

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
package com.andre601.javabotblockapi.requests;
2020

2121

22+
import net.dv8tion.jda.api.JDA;
23+
import net.dv8tion.jda.api.sharding.ShardManager;
24+
import org.json.JSONObject;
25+
2226
/**
2327
* Class to perform GET actions with.
2428
*/
@@ -44,4 +48,160 @@ public GetAction(){
4448
public GetAction(boolean disableCache){
4549
this.disableCache = disableCache;
4650
}
51+
52+
/**
53+
* Gets the full information of a bot.
54+
* <br>This may return null.
55+
*
56+
* <p>The JSONObject may look like this:
57+
* <br><pre><code>
58+
* {
59+
* "id": "123456789012345678",
60+
* "username": "MyBot",
61+
* "discriminator": "1234",
62+
* "owners": [
63+
* "234567890123456789"
64+
* ],
65+
* "server_count": 100,
66+
* "invite":{@literal "https://discordapp.com/oauth2/authorize?client_id=123456789012345678&scope=bot"},
67+
* "list_data": {
68+
* "somebotlist.com": [
69+
* {"data"},
70+
* 200
71+
* ],
72+
* "otherlist.org": [
73+
* {"data"},
74+
* 404
75+
* ]
76+
* }
77+
* }
78+
* </code></pre>
79+
* <br><b>{@code {"data"}}</b> depends on what the bot list returns.
80+
*
81+
* @param jda
82+
* The {@link net.dv8tion.jda.api.JDA JDA instance} to use.
83+
*
84+
* @return A possibly-null JSONObject containing the bots information.
85+
*/
86+
public JSONObject getAll(JDA jda){
87+
return REQUEST_HANDLER.performGetBot(jda.getSelfUser().getId(), disableCache);
88+
}
89+
90+
/**
91+
* Gets the full information of a bot.
92+
* <br>This may return null.
93+
*
94+
* <p>The JSONObject may look like this:
95+
* <br><pre><code>
96+
* {
97+
* "id": "123456789012345678",
98+
* "username": "MyBot",
99+
* "discriminator": "1234",
100+
* "owners": [
101+
* "234567890123456789"
102+
* ],
103+
* "server_count": 100,
104+
* "invite":{@literal "https://discordapp.com/oauth2/authorize?client_id=123456789012345678&scope=bot"},
105+
* "list_data": {
106+
* "somebotlist.com": [
107+
* {"data"},
108+
* 200
109+
* ],
110+
* "otherlist.org": [
111+
* {"data"},
112+
* 404
113+
* ]
114+
* }
115+
* }
116+
* </code></pre>
117+
* <br><b>{@code {"data"}}</b> depends on what the bot list returns.
118+
*
119+
* @param id
120+
* The bots id to use.
121+
*
122+
* @return A possibly-null JSONObject containing the bots information.
123+
*/
124+
public JSONObject getAll(Long id){
125+
return REQUEST_HANDLER.performGetBot(Long.toString(id), disableCache);
126+
}
127+
128+
/**
129+
* Gets the full information of a bot.
130+
* <br>This may return null.
131+
*
132+
* <p>The JSONObject may look like this:
133+
* <br><pre><code>
134+
* {
135+
* "id": "123456789012345678",
136+
* "username": "MyBot",
137+
* "discriminator": "1234",
138+
* "owners": [
139+
* "234567890123456789"
140+
* ],
141+
* "server_count": 100,
142+
* "invite":{@literal "https://discordapp.com/oauth2/authorize?client_id=123456789012345678&scope=bot"},
143+
* "list_data": {
144+
* "somebotlist.com": [
145+
* {"data"},
146+
* 200
147+
* ],
148+
* "otherlist.org": [
149+
* {"data"},
150+
* 404
151+
* ]
152+
* }
153+
* }
154+
* </code></pre>
155+
* <br><b>{@code {"data"}}</b> depends on what the bot list returns.
156+
*
157+
* @param shardManager
158+
* The {@link net.dv8tion.jda.api.sharding.ShardManager ShardManager instance} to use.
159+
*
160+
* @return A possibly-null JSONObject containing the bots information.
161+
*/
162+
public JSONObject getAll(ShardManager shardManager){
163+
JDA jda = shardManager.getShardById(0);
164+
if(jda == null)
165+
return null;
166+
167+
return REQUEST_HANDLER.performGetBot(jda.getSelfUser().getId(), disableCache);
168+
}
169+
170+
/**
171+
* Gets the full information of a bot.
172+
* <br>This may return null.
173+
*
174+
* <p>The JSONObject may look like this:
175+
* <br><pre><code>
176+
* {
177+
* "id": "123456789012345678",
178+
* "username": "MyBot",
179+
* "discriminator": "1234",
180+
* "owners": [
181+
* "234567890123456789"
182+
* ],
183+
* "server_count": 100,
184+
* "invite":{@literal "https://discordapp.com/oauth2/authorize?client_id=123456789012345678&scope=bot"},
185+
* "list_data": {
186+
* "somebotlist.com": [
187+
* {"data"},
188+
* 200
189+
* ],
190+
* "otherlist.org": [
191+
* {"data"},
192+
* 404
193+
* ]
194+
* }
195+
* }
196+
* </code></pre>
197+
* <br><b>{@code {"data"}}</b> depends on what the bot list returns.
198+
*
199+
* @param id
200+
* The bots id to use.
201+
*
202+
* @return A possibly-null JSONObject containing the bots information.
203+
*/
204+
public JSONObject getAll(String id){
205+
return REQUEST_HANDLER.performGetBot(id, disableCache);
206+
}
47207
}

0 commit comments

Comments
 (0)