Merge branch 'dev-merge' into hax-dev
This commit is contained in:
commit
1efeacd55a
5 changed files with 117 additions and 1 deletions
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
* @GregTCLTK @Schlauer-Hax
|
||||||
|
|
@ -23,6 +23,8 @@ import java.util.List;
|
||||||
|
|
||||||
public class Hadder {
|
public class Hadder {
|
||||||
|
|
||||||
|
public static ShardManager shardManager;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
startBot();
|
startBot();
|
||||||
}
|
}
|
||||||
|
|
@ -66,7 +68,7 @@ public class Hadder {
|
||||||
new ReadyListener(rethink));
|
new ReadyListener(rethink));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ShardManager shardManager = builder.build();
|
shardManager = builder.build();
|
||||||
} catch (LoginException e) {
|
} catch (LoginException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ package com.bbn.hadder.listener;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.bbn.hadder.Rethink;
|
import com.bbn.hadder.Rethink;
|
||||||
|
import com.bbn.hadder.utils.BotList;
|
||||||
import com.bbn.hadder.utils.MessageEditor;
|
import com.bbn.hadder.utils.MessageEditor;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
|
@ -40,6 +41,8 @@ public class GuildListener extends ListenerAdapter {
|
||||||
.setFooter(event.getJDA().getSelfUser().getName(), event.getJDA().getSelfUser().getAvatarUrl())
|
.setFooter(event.getJDA().getSelfUser().getName(), event.getJDA().getSelfUser().getAvatarUrl())
|
||||||
.setTimestamp(Instant.now())
|
.setTimestamp(Instant.now())
|
||||||
.build()).queue();
|
.build()).queue();
|
||||||
|
|
||||||
|
BotList.post();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onGuildLeave(GuildLeaveEvent event) {
|
public void onGuildLeave(GuildLeaveEvent event) {
|
||||||
|
|
@ -52,6 +55,8 @@ public class GuildListener extends ListenerAdapter {
|
||||||
.setFooter(event.getJDA().getSelfUser().getName(), event.getJDA().getSelfUser().getAvatarUrl())
|
.setFooter(event.getJDA().getSelfUser().getName(), event.getJDA().getSelfUser().getAvatarUrl())
|
||||||
.setTimestamp(Instant.now())
|
.setTimestamp(Instant.now())
|
||||||
.build()).queue();
|
.build()).queue();
|
||||||
|
|
||||||
|
BotList.post();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
|
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.bbn.hadder.listener;
|
package com.bbn.hadder.listener;
|
||||||
|
|
||||||
import com.bbn.hadder.Rethink;
|
import com.bbn.hadder.Rethink;
|
||||||
|
import com.bbn.hadder.utils.BotList;
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
import net.dv8tion.jda.api.events.ReadyEvent;
|
import net.dv8tion.jda.api.events.ReadyEvent;
|
||||||
|
|
@ -27,5 +28,7 @@ public class ReadyListener extends ListenerAdapter {
|
||||||
for (Guild g : event.getJDA().getGuilds()) {
|
for (Guild g : event.getJDA().getGuilds()) {
|
||||||
rethink.insertServer(g.getId());
|
rethink.insertServer(g.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BotList.post();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
105
src/main/java/com/bbn/hadder/utils/BotList.java
Normal file
105
src/main/java/com/bbn/hadder/utils/BotList.java
Normal file
|
|
@ -0,0 +1,105 @@
|
||||||
|
package com.bbn.hadder.utils;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author Skidder / GregTCLTK
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.bbn.hadder.Hadder;
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
public class BotList {
|
||||||
|
|
||||||
|
private static String MythicalBotList = "https://mythicalbots.xyz/api/bot/637002314162372639";
|
||||||
|
private static String BotsForDiscord = "https://botsfordiscord.com/api/bot/637002314162372639";
|
||||||
|
private static String DiscordBotList = "https://discordbotlist.com/api/bots/637002314162372639/stats";
|
||||||
|
private static String DiscordBestBots = "https://discordsbestbots.xyz/api/bots/637002314162372639/stats";
|
||||||
|
|
||||||
|
private static JSONObject json = new JSONObject();
|
||||||
|
|
||||||
|
public static void post() {
|
||||||
|
json.put("server_count", Hadder.shardManager.getGuilds().size());
|
||||||
|
json.put("guilds", Hadder.shardManager.getGuilds().size());
|
||||||
|
json.put("users", Hadder.shardManager.getUsers().size());
|
||||||
|
|
||||||
|
RequestBody body = RequestBody.create(MediaType.parse("application/json"), json.toString());
|
||||||
|
|
||||||
|
File configfile = new File("./config.json");
|
||||||
|
|
||||||
|
JSONObject config = null;
|
||||||
|
try {
|
||||||
|
config = new JSONObject(new String(Files.readAllBytes(Paths.get(configfile.toURI()))));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mythical Bot List
|
||||||
|
|
||||||
|
Request mythicalbotlist = new Request.Builder()
|
||||||
|
.url(MythicalBotList)
|
||||||
|
.post(body)
|
||||||
|
.addHeader("Authorization", config.getString("MythicalBotList"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
new OkHttpClient().newCall(mythicalbotlist).execute().close();
|
||||||
|
System.out.println("Successfully posted count for the Mythical Bot List!");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// BotsForDiscord
|
||||||
|
|
||||||
|
Request botsfordiscord = new Request.Builder()
|
||||||
|
.url(BotsForDiscord)
|
||||||
|
.post(body)
|
||||||
|
.addHeader("Authorization", config.getString("BotsForDiscord"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
new OkHttpClient().newCall(botsfordiscord).execute().close();
|
||||||
|
System.out.println("Successfully posted count to Bots For Discord!");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Discord Bot List
|
||||||
|
|
||||||
|
Request discordbotlist = new Request.Builder()
|
||||||
|
.url(DiscordBotList)
|
||||||
|
.post(body)
|
||||||
|
.addHeader("Authorization", "Bot " + config.getString("DiscordBotList"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
new OkHttpClient().newCall(discordbotlist).execute().close();
|
||||||
|
System.out.println("Successfully posted count for the Discord Bot List");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Discord Best Bots
|
||||||
|
|
||||||
|
Request discordbestbots = new Request.Builder()
|
||||||
|
.url(DiscordBestBots)
|
||||||
|
.post(body)
|
||||||
|
.addHeader("Authorization", config.getString("DiscordBestBots"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
new OkHttpClient().newCall(discordbestbots).execute().close();
|
||||||
|
System.out.println("Successfully posted count to Discord Best Bots!");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue