more shit

i should mention im doing live tests before upload, and this is
pre-maintenance, anything worth noting will be written in comments

Signed-off-by: deepCurse <leverplays@gmail.com>
This commit is contained in:
lever1209 2021-12-06 10:58:30 -04:00
commit 1380bc2a22
No known key found for this signature in database
GPG key ID: EEBCBB60C9DFC782
24 changed files with 663 additions and 288 deletions

View file

@ -7,15 +7,14 @@ import pkg.deepCurse.nopalmo.command.GuildCommand;
import pkg.deepCurse.nopalmo.database.DatabaseTools.Tools.Global;
import pkg.deepCurse.nopalmo.manager.Argument;
import pkg.deepCurse.nopalmo.manager.GuildCommandBlob;
import pkg.deepCurse.nopalmo.manager.GuildCommandManager;
import pkg.deepCurse.nopalmo.utils.UptimePing;
public class Ping extends GuildCommand {
@Override
public void runCommand(GuildCommandBlob blob, GuildCommandManager commandManager,
HashMap<String, Argument> argumentMap) throws Exception {
public void runCommand(GuildCommandBlob blob, HashMap<String, Argument> argumentMap) throws Exception {
GuildMessageReceivedEvent event = blob.getGuildMessageEvent();
GuildMessageReceivedEvent event = blob.getEvent();
if (argumentMap.isEmpty()) {
event.getChannel().sendMessage("Pong!\n" + event.getJDA().getGatewayPing() + "ms\n").queue();
@ -27,17 +26,28 @@ public class Ping extends GuildCommand {
event.getChannel().sendMessage("Gathering data. . .").queue(msg -> {
long timeToProcess = System.currentTimeMillis();
try { // TODO rewrite this block, all tries are not good practice
String out = "Pong!\n" + "Google: " + services.UptimePing.sendPing("www.google.com") + "ms\n"
+ "JDA Gateway: " + event.getJDA().getGatewayPing() + "ms\n" + "www.discord.com: "
+ services.UptimePing.sendPing("www.discord.com") + "ms";
msg.editMessage(out + "\nTime to process: " + (System.currentTimeMillis() - timeToProcess) + "ms")
.queue();
long jdaPing = event.getJDA().getGatewayPing();
long googlePing = -1;
try {
googlePing = UptimePing.sendPing("www.google.com");
} catch (Exception e) {
e.printStackTrace();
}
long discordPing = -1;
try {
discordPing = UptimePing.sendPing("www.discord.com");
} catch (Exception e) {
e.printStackTrace();
}
String out = "Ping:\n"
+ (googlePing > 0 ? "Google: " + googlePing + "ms\n" : "Could not connect to www.google.com\n")
+ (discordPing > 0 ? "Discord: " + discordPing + "ms\n"
: "Could not connect to www.discord.com\n")
+ "JDA-Discord heartbeat: "+jdaPing+"ms";
msg.editMessage(out + "\nTime to process: " + (System.currentTimeMillis() - timeToProcess) + "ms")
.queue();
});
}
@ -64,7 +74,7 @@ public class Ping extends GuildCommand {
@Override
public String getUsage() {
return Global.prefix+"ping [" + Argument.argumentPrefix + "all]";
return Global.prefix + "ping [" + Argument.argumentPrefix + "all]";
}
@Override