Skip to content
This repository has been archived by the owner on Jun 19, 2021. It is now read-only.

Commit

Permalink
Make things look nice
Browse files Browse the repository at this point in the history
  • Loading branch information
duplexsystem committed Jan 31, 2021
1 parent af53185 commit 8fb2689
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 33 deletions.
6 changes: 2 additions & 4 deletions src/main/java/org/yatopiamc/bot/YatopiaBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yatopiamc.bot.commands.CommandAsk;
import org.yatopiamc.bot.commands.CommandDownloadSpecific;
import org.yatopiamc.bot.commands.CommandJDKSpecific;
import org.yatopiamc.bot.commands.CommandMappingSpecific;
Expand Down Expand Up @@ -121,9 +120,9 @@ public void start() throws LoginException, InterruptedException, IOException {
settings.setHelpCommandEmbed(
() ->
EmbedUtil.defaultEmbed()
.setTitle("`()` - optional ; `[]` - required")
.setTitle("Yatopia Bot -- `()` - optional, `[]` - required")
.setThumbnail(
"https://cdn.discordapp.com/attachments/745296670631395482/745298764788400238/yatipia.png"));
"https://yatopiamc.org/static/img/yatopia-shiny.gif"));
settings.setFailReasonHandler(null);
settings.setCommandsPerHelpPage(10);
settings.setLogExecutedCommands(true);
Expand All @@ -137,7 +136,6 @@ public void start() throws LoginException, InterruptedException, IOException {
new CommandJDKSpecific(),
new CommandDownloadSpecific(),
new CommandYatopiaSpecific(),
new CommandAsk(),
new CommandVanilla(),
new CommandUpstream(),
new CommandMappingSpecific(this),
Expand Down
26 changes: 0 additions & 26 deletions src/main/java/org/yatopiamc/bot/commands/CommandAsk.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
Expand All @@ -20,10 +21,12 @@
import org.slf4j.LoggerFactory;
import org.yatopiamc.bot.util.NetworkUtils;

import java.awt.*;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -84,7 +87,11 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
final CompletableFuture<Message> inProgress = inProgress(message);
final CompletableFuture<SimpleHttpResponse> timingsJsonRequest = loadingCache.getUnchecked(timingsHost + "data.php?id=" + timingsId);
final EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setTitle("Timings Analysis", url);
final User messageAuthor = event.getAuthor();
embedBuilder.setTitle("Timings Analysis"); //remove url because people delete timings reports
embedBuilder.setColor(0xffff00);
embedBuilder.setTimestamp(Instant.now());
embedBuilder.setAuthor(messageAuthor.getAsTag(), messageAuthor.getEffectiveAvatarUrl(), messageAuthor.getEffectiveAvatarUrl());
timingsJsonRequest.handleAsync((response, throwable) -> {
boolean hasError = false;
long startProcessingTime = System.currentTimeMillis();
Expand Down Expand Up @@ -136,7 +143,8 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
}
embedBuilder.addField(String.format("Plus %d more recommendations", size - 24), "Create a new timings report after resolving some of the above issues to see more.", false);
}
embedBuilder.setFooter(String.format("Timing: %dms network, %dms processing", startProcessingTime - startTime, System.currentTimeMillis() - startProcessingTime));
embedBuilder.setFooter(String.format("https://yatopiamc.org/ • Timing: %dms network, %dms processing", startProcessingTime - startTime, System.currentTimeMillis() - startProcessingTime),
event.getJDA().getSelfUser().getEffectiveAvatarUrl());
inProgress.handle((msg, t) -> {
if(msg != null) {
msg.editMessage(embedBuilder.build()).queue();
Expand Down Expand Up @@ -219,7 +227,7 @@ private void checkSystem(EmbedBuilder embedBuilder, JsonObject timingsMaster) {
private void checkCPU(EmbedBuilder embedBuilder, JsonObject system) {
final int cpu = system.get("cpu").getAsInt();
if(cpu < 4)
embedBuilder.addField("CPU Threads", String.format("You have only %d thread(s). Find a better host", cpu), true);
embedBuilder.addField("CPU Threads", String.format("You have only %d thread(s). Find a better host.", cpu), true);
}

private void checkJvmFlags(EmbedBuilder embedBuilder, JsonObject system) {
Expand Down

0 comments on commit 8fb2689

Please sign in to comment.