Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit e63c384

Browse files
authored
Merge pull request #106 from BigBotNetwork/dev
Dev
2 parents 7ef5632 + f45d157 commit e63c384

File tree

4 files changed

+78
-141
lines changed

4 files changed

+78
-141
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,12 @@
120120
<artifactId>google-api-client-appengine</artifactId>
121121
<version>1.23.0</version>
122122
</dependency>
123+
<!-- https://mvnrepository.com/artifact/com.github.cliftonlabs/json-simple -->
124+
<dependency>
125+
<groupId>com.github.cliftonlabs</groupId>
126+
<artifactId>json-simple</artifactId>
127+
<version>2.1.2</version>
128+
</dependency>
129+
123130
</dependencies>
124131
</project>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package commands.tools;
2+
3+
import com.google.gson.JsonObject;
4+
import com.google.gson.JsonParser;
5+
import commands.Command;
6+
import de.foryasee.httprequest.*;
7+
import net.dv8tion.jda.core.EmbedBuilder;
8+
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
9+
10+
import java.io.IOException;
11+
12+
public class CommandBotInfo implements Command {
13+
@Override
14+
public boolean called(String[] args, MessageReceivedEvent event) {
15+
return false;
16+
}
17+
@Override
18+
public void action(String[] args, MessageReceivedEvent event) {
19+
if (args.length == 0 || args.length == 1 || args.length == 2) {
20+
if (event.getMessage().getContentRaw().endsWith("dbw")) {
21+
event.getTextChannel().sendMessage("Discord Bot World").queue();
22+
23+
24+
25+
try {
26+
HttpRequestBuilder httpRequestBuilder = new HttpRequestBuilder("https://discordbot.world/api/bot/" + args[0] + "/info", RequestType.GET);
27+
RequestResponse requestResponse = httpRequestBuilder.sendRequest();
28+
System.out.println(requestResponse.getResponseMessage());
29+
30+
JsonObject jsonObject = new JsonParser().parse(requestResponse.getResponseMessage()).getAsJsonObject();
31+
event.getTextChannel().sendMessage(jsonObject.toString()).queue();
32+
event.getTextChannel().sendMessage(new EmbedBuilder().setThumbnail(jsonObject.get("avatar").getAsString()).setTitle("Botinfo: " + jsonObject.get("name").getAsString()).build()).queue();
33+
34+
} catch (IOException e) {
35+
e.printStackTrace();
36+
}
37+
38+
} else if (event.getMessage().getContentRaw().endsWith("dbl")) {
39+
40+
41+
event.getTextChannel().sendMessage("Discord Bots").queue();
42+
43+
44+
} else {
45+
46+
47+
event.getTextChannel().sendMessage("Nothing :(").queue();
48+
49+
50+
}
51+
52+
53+
54+
55+
} else {
56+
event.getTextChannel().sendMessage("Zu kurz!").queue();
57+
}
58+
}
59+
@Override
60+
public void executed(boolean success, MessageReceivedEvent event) {
61+
62+
}
63+
}

src/main/java/core/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public static void main(String[] args2) {
110110
commandHandler.commands.put("shard", new CommandShard());
111111
commandHandler.commands.put("uptime", new CommandUptime());
112112
commandHandler.commands.put("role", new CommandRole());
113+
commandHandler.commands.put("botinfo", new CommandBotInfo());
113114
/*MUSIC*/
114115
commandHandler.commands.put("join", new CommandJoin());
115116
commandHandler.commands.put("leave", new commands.music.CommandLeave());

src/main/java/listener/BotList.java

Lines changed: 7 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@
2222
import static core.Main.jda;
2323

2424
public class BotList extends ListenerAdapter {
25+
26+
String botlistspace_url = "https://botlist.space/api/bots/407189087649398795";
27+
String botsfordiscord_url = "https://botsfordiscord.com/api/v1/bots/407189087649398795";
28+
29+
30+
JSONObject data = new JSONObject();
31+
2532
@Override
2633
public void onGuildJoin(GuildJoinEvent event) {
2734

28-
String botlistspace_url = "https://botlist.space/api/bots/407189087649398795";
29-
JSONObject data = new JSONObject();
3035
data.put("shard_id", event.getJDA().getShardInfo().getShardId());
3136
data.put("shard_count", Main.shardManager.getShardsTotal());
3237
data.put("server_count", Main.shardManager.getGuilds().size());
@@ -45,92 +50,11 @@ public void onGuildJoin(GuildJoinEvent event) {
4550
e.printStackTrace();
4651
}
4752

48-
49-
String botsfordiscord_url = "https://botsfordiscord.com/api/v1/bots/407189087649398795";
50-
51-
data.put("server_count", Main.shardManager.getGuilds().size());
52-
53-
54-
Request botsfordiscord = new Request.Builder()
55-
.url(botsfordiscord_url)
56-
.post(body)
57-
.addHeader("Authorization", SECRETS.botsfordiscord)
58-
.build();
59-
60-
try {
61-
new OkHttpClient().newCall(botsfordiscord).execute().close();
62-
System.out.println("Successfully posted count for Bots for Discord!");
63-
} catch (IOException e) {
64-
e.printStackTrace();
65-
}
66-
67-
String discordpw_url = "https://bots.discord.pw/api/bots/407189087649398795/stats";
68-
69-
data.put("shard_id", event.getJDA().getShardInfo().getShardId());
70-
data.put("shard_count", Main.shardManager.getShardsTotal());
71-
data.put("server_count", Main.shardManager.getGuilds().size());
72-
73-
74-
Request discordpw = new Request.Builder()
75-
.url(discordpw_url)
76-
.post(body)
77-
.addHeader("Authorization", SECRETS.discordpw)
78-
.build();
79-
80-
try {
81-
new OkHttpClient().newCall(discordpw).execute().close();
82-
System.out.println("Successfully posted count for discord.pw!");
83-
} catch (IOException e) {
84-
e.printStackTrace();
85-
}
86-
87-
88-
String discordbots_url = "https://bots.discord.pw/api/bots/407189087649398795/stats";
89-
90-
data.put("shard_id", event.getJDA().getShardInfo().getShardId());
91-
data.put("shard_count", Main.shardManager.getShardsTotal());
92-
data.put("server_count", Main.shardManager.getGuilds().size());
93-
94-
95-
Request discordbots = new Request.Builder()
96-
.url(discordbots_url)
97-
.post(body)
98-
.addHeader("Authorization", SECRETS.discordbots)
99-
.build();
100-
101-
try {
102-
new OkHttpClient().newCall(discordbots).execute().close();
103-
System.out.println("Successfully posted count for discord.pw!");
104-
} catch (IOException e) {
105-
e.printStackTrace();
106-
}
107-
108-
109-
String discordbotworld_url = "https://discordbot.world/api/bot/407189087649398795/stats";
110-
111-
data.put("shard_count", Main.shardManager.getShardsTotal());
112-
data.put("server_count", Main.shardManager.getGuilds().size());
113-
114-
115-
Request discordbotworld = new Request.Builder()
116-
.url(discordbotworld_url)
117-
.post(body)
118-
.addHeader("Authorization", SECRETS.botworld)
119-
.build();
120-
121-
try {
122-
new OkHttpClient().newCall(discordbotworld).execute().close();
123-
System.out.println("Successfully posted count for discordbot.world!");
124-
} catch (IOException e) {
125-
e.printStackTrace();
126-
}
12753
}
12854

12955

13056
public void onGuildLeave(GuildLeaveEvent event) {
13157

132-
String botlistspace_url = "https://botlist.space/api/bots/407189087649398795";
133-
JSONObject data = new JSONObject();
13458
data.put("shard_id", event.getJDA().getShardInfo().getShardId());
13559
data.put("shard_count", Main.shardManager.getShardsTotal());
13660
data.put("server_count", Main.shardManager.getGuilds().size());
@@ -148,63 +72,5 @@ public void onGuildLeave(GuildLeaveEvent event) {
14872
} catch (IOException e) {
14973
e.printStackTrace();
15074
}
151-
152-
153-
String botsfordiscord_url = "https://botsfordiscord.com/api/v1/bots/407189087649398795";
154-
155-
data.put("server_count", "91");
156-
157-
158-
Request botsfordiscord = new Request.Builder()
159-
.url(botsfordiscord_url)
160-
.post(body)
161-
.addHeader("Authorization", SECRETS.botsfordiscord)
162-
.build();
163-
164-
try {
165-
new OkHttpClient().newCall(botsfordiscord).execute().close();
166-
System.out.println("Successfully posted count for Bots for Discord!");
167-
} catch (IOException e) {
168-
e.printStackTrace();
169-
}
170-
171-
String discordpw_url = "https://bots.discord.pw/api/bots/407189087649398795/stats";
172-
173-
data.put("shard_id", event.getJDA().getShardInfo().getShardId());
174-
data.put("shard_count", Main.shardManager.getShardsTotal());
175-
data.put("server_count", Main.shardManager.getGuilds().size());
176-
177-
178-
Request discordpw = new Request.Builder()
179-
.url(discordpw_url)
180-
.post(body)
181-
.addHeader("Authorization", SECRETS.discordpw)
182-
.build();
183-
184-
try {
185-
new OkHttpClient().newCall(discordpw).execute().close();
186-
System.out.println("Successfully posted count for discord.pw!");
187-
} catch (IOException e) {
188-
e.printStackTrace();
189-
}
190-
191-
String discordbotworld_url = "https://discordbot.world/api/bot/407189087649398795/stats";
192-
193-
data.put("shard_count", Main.shardManager.getShardsTotal());
194-
data.put("server_count", Main.shardManager.getGuilds().size());
195-
196-
197-
Request discordbotworld = new Request.Builder()
198-
.url(discordbotworld_url)
199-
.post(body)
200-
.addHeader("Authorization", SECRETS.botworld)
201-
.build();
202-
203-
try {
204-
new OkHttpClient().newCall(discordbotworld).execute().close();
205-
System.out.println("Successfully posted count for discordbot.world!");
206-
} catch (IOException e) {
207-
e.printStackTrace();
208-
}
20975
}
21076
}

0 commit comments

Comments
 (0)