Closed NoPro200 closed 3 months ago
This is not error, JDA was unable to query members from one of guilds, so it was marked unavailable (probably of outage).
This is not error, JDA was unable to query members from one of guilds, so it was marked unavailable (probably of outage).
how can i fix this? because this is very important to me because i don't want to wait 1 minute and 30 seconds after every start
How many guilds is it on? How many members?
In any case I would not recommend caching all members
How many guilds is it on? How many members?
In any case I would not recommend caching all members
Guilds: 3 Members: 202, 4, 5
Which cache exactly?
About the member cache policy, and chunking filter, but I don't think it causes issues with a few members.
Have you also tried when not using any listeners
Can you send your build.gradle/pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>de.nopro200</groupId>
<artifactId>NoPros_Manager</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>dv8tion</id>
<name>m2-dv8tion</name>
<url>https://m2.dv8tion.net/releases</url>
</repository>
<repository>
<id>central</id>
<name>bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
<repository>
<id>arbjergDev</id>
<name>Lavalink Repository</name>
<url>https://maven.lavalink.dev/releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.1</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>com.github.mwiede</groupId>
<artifactId>jsch</artifactId>
<version>0.2.7</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.9.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.27</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>dev.arbjerg</groupId>
<artifactId>lavaplayer</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>dev.lavalink.youtube</groupId>
<artifactId>common</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.6</version>
</dependency>
<dependency>
<groupId>com.jagrosh</groupId>
<artifactId>jda-utilities</artifactId>
<version>3.0.5</version>
<scope>compile</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.cloudinary</groupId>
<artifactId>cloudinary-http44</artifactId>
<version>1.36.0</version>
</dependency>
<dependency>
<groupId>com.cloudinary</groupId>
<artifactId>cloudinary-taglib</artifactId>
<version>1.36.0</version>
</dependency>
<dependency>
<groupId>io.github.cdimascio</groupId>
<artifactId>dotenv-java</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.7</version>
</dependency>
</dependencies>
<build>
<finalName>NoPros_Manager</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>main.Hauptklasse</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<outputDirectory>J:\var\lib\pterodactyl\volumes\ec048743-b4c5-4dbf-9d13-24b9c7733ed0</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
without the Listeners it works :(
here is the Problem: package logs.analytics;
import main.Hauptklasse; import main.errortriggercode; import main.secrets; import main.variable; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.events.guild.GuildReadyEvent; import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent; import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import org.apache.commons.io.FileUtils;
import java.io.File; import java.nio.charset.StandardCharsets; import java.sql.Connection; import java.time.LocalDate; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.ResultSet; import java.util.*; import java.util.concurrent.CompletableFuture;
public class messageAndUserCountLog extends ListenerAdapter {
public void onMessageReceived(MessageReceivedEvent event) {
if (!event.getMessage().getAuthor().isSystem()) {
if (!event.getAuthor().isBot()) {
try {
LocalDate currentDate = LocalDate.now();
String dateString = currentDate.toString();
int messageCount = getMessageCountFromDiscord(Hauptklasse.connNormal, dateString) + 1;
if (messageCount == 1) {
String sql = "INSERT INTO message_counts (date, messagecount) VALUES (?, ?)";
PreparedStatement statement = Hauptklasse.connNormal.prepareStatement(sql);
statement.setString(1, dateString);
statement.setInt(2, messageCount);
statement.executeUpdate();
} else {
String sql = "UPDATE message_counts SET messagecount = ? WHERE date = ?";
PreparedStatement statement = Hauptklasse.connNormal.prepareStatement(sql);
statement.setInt(1, messageCount);
statement.setString(2, dateString);
statement.executeUpdate();
}
} catch (SQLException e) {
errortriggercode.sendERROR(e.toString(), "messageAndUserCountLog.java");
}
}
}
}
private static int getMessageCountFromDiscord(Connection connection, String dateString) throws SQLException {
int count = 0;
String selectSql = "SELECT messagecount FROM message_counts WHERE date = ?";
PreparedStatement selectStatement = connection.prepareStatement(selectSql);
selectStatement.setString(1, dateString);
ResultSet resultSet = selectStatement.executeQuery();
if (resultSet.next()) {
count = resultSet.getInt("messagecount");
}
return count;
}
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
if (event.getGuild().getId().equals(variable.ServerID)) {
changevalue(event.getGuild().getId(), event.getJDA());
}
}
public void onGuildMemberRemove(GuildMemberRemoveEvent event) {
if (event.getGuild().getId().equals(variable.ServerID)) {
changevalue(event.getGuild().getId(), event.getJDA());
}
}
public void onGuildReady(GuildReadyEvent event) {
if (event.getGuild().getId().equals(variable.ServerID)) {
changevalue(event.getJDA().getGuildById(variable.ServerID).getId(), event.getJDA());
}
}
public static void changevalue(String guildid, JDA jda) {
try {
LocalDate currentDate = LocalDate.now();
String dateString = currentDate.toString();
int memberCount = 0;
try {
memberCount = jda.awaitReady().getGuildById(variable.ServerID).getMemberCount();
} catch (Exception e) {}
if (!isEntryExists(dateString, Hauptklasse.connNormal)) {
String sql = "INSERT INTO member_counts (guild_id, date, membercount) VALUES (?, ?, ?)";
PreparedStatement statement = Hauptklasse.connNormal.prepareStatement(sql);
statement.setString(1, guildid);
statement.setString(2, dateString);
statement.setInt(3, memberCount);
statement.executeUpdate();
} else {
String sql = "UPDATE member_counts SET membercount = ? WHERE guild_id = ? AND date = ?";
PreparedStatement statement = Hauptklasse.connNormal.prepareStatement(sql);
statement.setInt(1, memberCount);
statement.setString(2, guildid);
statement.setString(3, dateString);
statement.executeUpdate();
}
} catch (SQLException e) {
errortriggercode.sendERROR(e.toString(), "messageAndUserCountLog.java");
}
}
public static boolean isEntryExists(String dateString, Connection connection) throws SQLException {
String selectSql = "SELECT COUNT(*) FROM member_counts WHERE date = ?";
PreparedStatement selectStatement = connection.prepareStatement(selectSql);
selectStatement.setString(1, dateString);
ResultSet resultSet = selectStatement.executeQuery();
resultSet.next();
int count = resultSet.getInt(1);
return count > 0;
}
public static String htmlCode(String guildid, JDA jda) {
try {
int[] memberCountForLast7Days = getMemberCountForLast7Days(guildid, Hauptklasse.connNormal);
int[] messageCountFromTheLast7Days = getMessageCountForLast7Days(Hauptklasse.connNormal);
int[] voicechanneltotaldurationinminutescount = getVoteCount(Hauptklasse.connNormal);
int[] voicetopusercount = getTopVoiceUserCountForLast7Days(Hauptklasse.connNormal);
String[] topUserIds = getTopUserIds();
String username1 = getAvatarAndTag(topUserIds[0])[0];
if (username1.endsWith("#0000")) {
username1 = username1.substring(0, username1.length() - 5);
}
String username2 = getAvatarAndTag(topUserIds[1])[0];
if (username2.endsWith("#0000")) {
username2 = username2.substring(0, username2.length() - 5);
}
String username3 = getAvatarAndTag(topUserIds[2])[0];
if (username3.endsWith("#0000")) {
username3 = username3.substring(0, username3.length() - 5);
}
String username4 = getAvatarAndTag(topUserIds[3])[0];
if (username4.endsWith("#0000")) {
username4 = username4.substring(0, username4.length() - 5);
}
String username5 = getAvatarAndTag(topUserIds[4])[0];
if (username5.endsWith("#0000")) {
username5 = username5.substring(0, username5.length() - 5);
}
String username6 = getAvatarAndTag(topUserIds[5])[0];
if (username6.endsWith("#0000")) {
username6 = username6.substring(0, username6.length() - 5);
}
String username7 = getAvatarAndTag(topUserIds[6])[0];
if (username7.endsWith("#0000")) {
username7 = username7.substring(0, username7.length() - 5);
}
String profilepicture1 = getAvatarAndTag(topUserIds[0])[1];
String profilepicture2 = getAvatarAndTag(topUserIds[1])[1];
String profilepicture3 = getAvatarAndTag(topUserIds[2])[1];
String profilepicture4 = getAvatarAndTag(topUserIds[3])[1];
String profilepicture5 = getAvatarAndTag(topUserIds[4])[1];
String profilepicture6 = getAvatarAndTag(topUserIds[5])[1];
String profilepicture7 = getAvatarAndTag(topUserIds[6])[1];
int[] Messagecount = getMessageCountsForTopUsers(Hauptklasse.connNormal, topUserIds);
StringBuilder html = new StringBuilder(
"<!DOCTYPE html>\n" +
"<html lang=\"en\">\n" +
"<head>\n" +
" <meta charset=\"UTF-8\">\n" +
" <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n" +
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" +
" <meta property=\"og:title\" content=\"NoPro200 - Discord Analytics\" />\n" +
" <meta property=\"og:description\" content=\"Hier findest du ein paar Analytics zu der NoPro200 Community\" />\n" +
"\t <meta property=\"og:image\" content=\"https://i.imgur.com/cfqN05p.png\" />\n" +
"\t <meta property=\"og:url\" content=\"https://nopro200.de\" />\n" +
" <title>NoPro200 - Discord Analytics</title>\n" +
" <link rel=\"icon\" type=\"image/png\" href=\"https://i.imgur.com/cfqN05p.png\">\n" +
" <script src=\"https://cdn.jsdelivr.net/npm/chart.js\"></script>\n" +
" <style>\n" +
" /* Scroll Bar */\n" +
" ::-webkit-scrollbar {\n" +
" width: 0px;\n" +
" }\n" +
" body {\n" +
" background-color: #222;\n" +
" font-family: sans-serif;\n" +
" color: #fff;\n" +
" }\n" +
" canvas {\n" +
" background-color: #333;\n" +
" width: 100%;\n" +
" }\n" +
" a {\n" +
" color: rgb(255, 255, 255);\n" +
" text-decoration: none;\n" +
" }\n" +
" .obena {\n" +
" margin-left: 2px;\n" +
" margin-right: 30px;\n" +
" font-size: 11px;\n" +
" margin-top: 20px;\n" +
" margin-bottom: 20px;\n" +
" }\n" +
" .obena:hover {\n" +
" text-decoration: underline;\n" +
" text-underline-position: below;\n" +
" text-underline-offset: 2px;\n" +
" }\n" +
" .überschrift {\n" +
" color: rgb(255, 255, 255);\n" +
" margin-left: 30px;\n" +
" font-size: 11px;\n" +
" }\n" +
" .hauptcontainer {\n" +
" display: flex; /* Anpassung: Flexbox verwenden */\n" +
" flex-wrap: warp;\n" +
" justify-content: space-between; /* Anpassung: Platz zwischen den Diagrammen */\n" +
" align-items: felx-start;\n" +
" text-align: center;\n" +
" max-width: 100%;\n" +
" }\n" +
" .chart-container {\n" +
" width: 49.5%;\n" +
" max-width: 100%;\n" +
" }\n" +
" canvas {\n" +
" margin-top: 10px;\n" +
" border-radius: 20px;\n" +
" }\n" +
" .oben {\n" +
" display: flex;\n" +
" justify-content: space-between;\n" +
" align-items: center;\n" +
" border-radius: 10px;\n" +
" background-color: black;\n" +
" height: 40px;\n" +
" }\n" +
" .topuser {\n" +
" justify-content: space-between;\n" +
" font-size: 20px;\n" +
" }\n" +
" .imgfromtopuser1 {\n" +
" border-radius: 300px;\n" +
" width: 50px;\n" +
" margin-right: 10px;\n" +
" margin-left: 10px;\n" +
" }\n" +
" .top1user {\n" +
" text-align: center;\n" +
" align-items: center;\n" +
" }\n" +
" .imgfromtopuser {\n" +
" border-radius: 300px;\n" +
" width: 50px;\n" +
" margin-right: 10px;\n" +
" margin-left: 10px;\n" +
" margin-top: 24px;\n" +
" margin-bottom: 20px;\n" +
" }\n" +
" .topmessageuser {\n" +
" display: inline-block;\n" +
" margin-left: 20px;\n" +
" margin-bottom: 30px;\n" +
" }\n" +
" .topvoiceuser {\n" +
" display: inline-block;\n" +
" align-items: right;\n" +
" float: right;\n" +
" text-align: right;\n" +
" margin-right: 20px;\n" +
" margin-bottom: 30px;\n" +
" }\n" +
" table {\n" +
" margin: 0 auto; /* Zentriert die Tabelle */\n" +
" border-collapse: collapse; /* Entfernt die Lücken zwischen den Zellen */\n" +
" }\n" +
" th, td {\n" +
" padding: 12px; /* Fügt Abstand zwischen dem Inhalt und den Zellenrändern hinzu */\n" +
" border: 20px solid black; /* Fügt einen Rahmen um die Zellen hinzu */\n" +
" }\n" +
" th {\n" +
" background-color: white; /* Ändert die Hintergrundfarbe der Überschriften */\n" +
" border-color: white; /* Ändert die Farbe des Rahmens der Überschriften */\n" +
" }\n" +
" tr:nth-child(even) {\n" +
" background-color: #000000; /* Fügt eine Hintergrundfarbe für gerade Zeilen hinzu */\n" +
" }\n" +
" tr:nth-child(odd) {\n" +
" background-color: #000000; /* Fügt eine Hintergrundfarbe für ungerade Zeilen hinzu */\n" +
" }\n" +
" .top-container {\n" +
" display: flex;\n" +
" justify-content: space-between;\n" +
" }\n" +
"\n" +
" .top1,\n" +
" .top2,\n" +
" .top3,\n" +
" .top4,\n" +
" .top5,\n" +
" .top6,\n" +
" .top7 {\n" +
" background-color: rgb(49, 49, 49); \n" +
" border-radius: 20px; \n" +
" width: 352px;\n" +
" margin-bottom: 20px;\n" +
" display: flex;\n" +
" align-items: center;\n" +
" }\n" +
"\n" +
" .imgfromtopuser {\n" +
" border-radius: 300px;\n" +
" width: 50px;\n" +
" margin-right: 10px;\n" +
" margin-left: 10px;\n" +
" }\n" +
"\n" +
" .top1_Text,\n" +
" .top2_Text,\n" +
" .top3_Text,\n" +
" .top4_Text,\n" +
" .top5_Text,\n" +
" .top6_Text,\n" +
" .top7_Text {\n" +
" margin-left: 10px;\n" +
" flex: 1;\n" +
" }\n" +
" </style>\n" +
"</head>\n" +
"<body>\n" +
" <div class=\"oben\">\n" +
" <div>\n" +
" <p></p>\n" +
" <a class=\"überschrift\" href=\"https://nopro200.de\">NoPro200 - Discord Analytics</a>\n" +
" <p></p>\n" +
" </div>\n" +
" <div>\n" +
" <a class=\"obena\" href=\"https://dc.nopro200.de\">Diesen Discord betreten</a>\n" +
" <a class=\"obena\" href=\"https://nopro200.de/impressum\">Impressum & Datenschutz</a>\n" +
" </div>\n" +
" </div>\n" +
" <div class=\"hauptcontainer\">\n" +
" <div class=\"chart-container\">\n" +
" <canvas id=\"userChart\"></canvas>\n" +
" </div>\n" +
" <div class=\"chart-container\">\n" +
" <canvas id=\"messageChart\"></canvas>\n" +
" </div>\n" +
" </div>\n" +
" <div class=\"hauptcontainer\">\n" +
" <div class=\"chart-container\">\n" +
" <canvas id=\"voicechanneltalkduration\"></canvas>\n" +
" </div>\n" +
" <div class=\"chart-container\">\n" +
" <canvas id=\"voicechannelusercount\"></canvas>\n" +
" </div>\n" +
" </div>\n" +
" <div class=\"topuser\">\n" +
" <h1 style=\"text-align: center;\">Top 5 Aktive User</h1>\n" +
" <div class=\"top-container\">\n" +
" <div style=\"margin-left: 20px;\" class=\"top1\">\n" +
" <div class=\"image_blob\">\n" +
" <img class=\"imgfromtopuser\" src=\"" + profilepicture1 + "\">\n" +
" </div>\n" +
" <div class=\"top1_Text\">\n" +
" <p style=\"text-decoration: underline; text-underline-offset: 15px; font-size: 24px; color: #fff; text-shadow: 0 0 10px rgba(255, 255, 255, 0.7); \">Platz 1</p>\n" +
" <p>Name: " + username1 + "</p>\n" +
" <p>Nachrichtenanzahl: " + Messagecount[0] + "</p>\n" +
" </div>\n" +
" </div>\n" +
" \n" +
" <div class=\"top2\">\n" +
" <div class=\"image_blob\">\n" +
" <img class=\"imgfromtopuser\" src=\"" + profilepicture2 + "\">\n" +
" </div>\n" +
" <div class=\"top2_Text\">\n" +
" <p style=\"text-decoration: underline; text-underline-offset: 15px; font-size: 24px; color: #fff; text-shadow: 0 0 10px rgba(255, 255, 255, 0.7); \">Platz 2</p>\n" +
" <p>Name: " + username2 + "</p>\n" +
" <p>Nachrichtenanzahl: " + Messagecount[1] + "</p>\n" +
" </div>\n" +
" </div>\n" +
"\n" +
" <div class=\"top3\">\n" +
" <div class=\"image_blob\">\n" +
" <img class=\"imgfromtopuser\" src=\"" + profilepicture3 + "\">\n" +
" </div>\n" +
" <div class=\"top2_Text\">\n" +
" <p style=\"text-decoration: underline; text-underline-offset: 15px; font-size: 24px; color: #fff; text-shadow: 0 0 10px rgba(255, 255, 255, 0.7); \">Platz 3</p>\n" +
" <p>Name: " + username3 + "</p>\n" +
" <p>Nachrichtenanzahl: " + Messagecount[2] + "</p>\n" +
" </div>\n" +
" </div>\n" +
"\n" +
" <div class=\"top4\">\n" +
" <div class=\"image_blob\">\n" +
" <img class=\"imgfromtopuser\" src=\"" + profilepicture4 + "\">\n" +
" </div>\n" +
" <div class=\"top2_Text\">\n" +
" <p style=\"text-decoration: underline; text-underline-offset: 15px; font-size: 24px; color: #fff; text-shadow: 0 0 10px rgba(255, 255, 255, 0.7); \">Platz 4</p>\n" +
" <p>Name: " + username4 + "</p>\n" +
" <p>Nachrichtenanzahl: " + Messagecount[3] + "</p>\n" +
" </div>\n" +
" </div>\n" +
"\n" +
"\n" +
" \n" +
" <div style=\"margin-right: 20px;\" class=\"top5\">\n" +
" <div class=\"image_blob\">\n" +
" <img class=\"imgfromtopuser\" src=\"" + profilepicture5 + "\">\n" +
" </div>\n" +
" <div class=\"top2_Text\">\n" +
" <p style=\"text-decoration: underline; text-underline-offset: 15px; font-size: 24px; color: #fff; text-shadow: 0 0 10px rgba(255, 255, 255, 0.7); \">Platz 5</p>\n" +
" <p>Name: " + username5 + "</p>\n" +
" <p>Nachrichtenanzahl: " + Messagecount[4] + "</p>\n" +
" </div>\n" +
" </div>\n" +
"\n" +
"\n" +
"\n" +
" </div>\n" +
"\n" +
"\n" +
" </div>\n" +
" </div>\n" +
" </div>\n" +
"<script>\n" +
" // Canvas-Element auswählen\n" +
" var chartCanvas = document.getElementById(\"userChart\");\n" +
" var messageChart = document.getElementById(\"messageChart\");\n" +
" var voicechanneltalkduration = document.getElementById(\"voicechanneltalkduration\");\n" +
" var voicechannelusercount = document.getElementById(\"voicechannelusercount\");\n" +
"\n" +
" // Diagramm erstellen\n" +
" var userChart = new Chart(chartCanvas, {\n" +
" type: \"line\", // Diagrammtyp (hier: Liniendiagramm)\n" +
" data: {\n" +
" labels: [], // Beschriftungen der x-Achse\n" +
" datasets: [\n" +
" {\n" +
" label: \"Nutzer\",\n" +
" fill: 'start',\n" +
" backgroundColor: 'rgba(255, 0, 0, 0.3)',\n" +
" borderColor: \"rgba(255, 0, 0, 1)\",\n" +
" borderWidth: 2,\n" +
" lineTension: 0.4, // Rundung der Linie\n" +
" },\n" +
" ],\n" +
" },\n" +
" options: {\n" +
" responsive: true, // Diagrammgröße anpassen\n" +
" scales: {\n" +
" y: {\n" +
" beginAtZero: true, // y-Achse ab 0 beginnen\n" +
" grid: {\n" +
" color: \"rgba(255, 255, 255, 0.1)\", // Farbe der Gitterlinien\n" +
" },\n" +
" ticks: {\n" +
" fontColor: \"#ccc\", // Farbe der Achsenbeschriftungen\n" +
" },\n" +
" },\n" +
" x: {\n" +
" grid: {\n" +
" display: false, // Gitterlinien auf der x-Achse ausblenden\n" +
" },\n" +
" ticks: {\n" +
" fontColor: \"#ccc\", // Farbe der Achsenbeschriftungen\n" +
" },\n" +
" },\n" +
" },\n" +
" plugins: {\n" +
" legend: {\n" +
" labels: {\n" +
" color: \"#ccc\", // Farbe der Legendenbeschriftungen\n" +
" },\n" +
" },\n" +
" },\n" +
" },\n" +
" });\n" +
"\n" +
" // Diagramm erstellen\n" +
" var messageChartObj = new Chart(messageChart, {\n" +
" type: \"line\", // Diagrammtyp (hier: Liniendiagramm)\n" +
" data: {\n" +
" labels: [], // Beschriftungen der x-Achse\n" +
" datasets: [\n" +
" {\n" +
" label: \"Nachrichten\",\n" +
" fill: 'start',\n" +
" backgroundColor: 'rgba(75, 192, 192, 0.3)',\n" +
" borderColor: \"rgba(75, 192, 192, 1)\",\n" +
" borderWidth: 2,\n" +
" lineTension: 0.4, // Rundung der Linie\n" +
" },\n" +
" ],\n" +
" },\n" +
" options: {\n" +
" responsive: true, // Diagrammgröße anpassen\n" +
" scales: {\n" +
" y: {\n" +
" beginAtZero: true, // y-Achse ab 0 beginnen\n" +
" grid: {\n" +
" color: \"rgba(255, 255, 255, 0.1)\", // Farbe der Gitterlinien\n" +
" },\n" +
" ticks: {\n" +
" fontColor: \"#ccc\", // Farbe der Achsenbeschriftungen\n" +
" },\n" +
" },\n" +
" x: {\n" +
" grid: {\n" +
" display: false, // Gitterlinien auf der x-Achse ausblenden\n" +
" },\n" +
" ticks: {\n" +
" fontColor: \"#ccc\", // Farbe der Achsenbeschriftungen\n" +
" },\n" +
" },\n" +
" },\n" +
" plugins: {\n" +
" legend: {\n" +
" labels: {\n" +
" color: \"#ccc\", // Farbe der Legendenbeschriftungen\n" +
" },\n" +
" },\n" +
" },\n" +
" },\n" +
" });\n" +
" var voicechanneltalkdurationobj = new Chart(voicechanneltalkduration, {\n" +
" type: \"line\", // Diagrammtyp (hier: Liniendiagramm)\n" +
" data: {\n" +
" labels: [], // Beschriftungen der x-Achse\n" +
" datasets: [\n" +
" {\n" +
" label: \"Votes\",\n" +
" fill: 'start',\n" +
" backgroundColor: 'rgba(4, 255, 0, 0.3)',\n" +
" borderColor: \"rgba(4, 255, 0, 1)\",\n" +
" borderWidth: 2,\n" +
" lineTension: 0.4, // Rundung der Linie\n" +
" },\n" +
" ],\n" +
" },\n" +
" options: {\n" +
" responsive: true, // Diagrammgröße anpassen\n" +
" scales: {\n" +
" y: {\n" +
" beginAtZero: true, // y-Achse ab 0 beginnen\n" +
" grid: {\n" +
" color: \"rgba(255, 255, 255, 0.1)\", // Farbe der Gitterlinien\n" +
" },\n" +
" ticks: {\n" +
" fontColor: \"#ccc\", // Farbe der Achsenbeschriftungen\n" +
" },\n" +
" },\n" +
" x: {\n" +
" grid: {\n" +
" display: false, // Gitterlinien auf der x-Achse ausblenden\n" +
" },\n" +
" ticks: {\n" +
" fontColor: \"#ccc\", // Farbe der Achsenbeschriftungen\n" +
" },\n" +
" },\n" +
" },\n" +
" plugins: {\n" +
" legend: {\n" +
" labels: {\n" +
" color: \"#ccc\", // Farbe der Legendenbeschriftungen\n" +
" },\n" +
" },\n" +
" },\n" +
" },\n" +
" });\n" +
" var voicechannelusercountobj = new Chart(voicechannelusercount, {\n" +
" type: \"line\", // Diagrammtyp (hier: Liniendiagramm)\n" +
" data: {\n" +
" labels: [], // Beschriftungen der x-Achse\n" +
" datasets: [\n" +
" {\n" +
" label: \"User ingesamt im Talk gewesen (Top Usercount)\",\n" +
" fill: 'start',\n" +
" backgroundColor: 'rgba(255, 204, 0, 0.3)',\n" +
" borderColor: \"rgba(255, 204, 0, 1)\",\n" +
" borderWidth: 2,\n" +
" lineTension: 0.4, // Rundung der Linie\n" +
" },\n" +
" ],\n" +
" },\n" +
" options: {\n" +
" responsive: true, // Diagrammgröße anpassen\n" +
" scales: {\n" +
" y: {\n" +
" beginAtZero: true, // y-Achse ab 0 beginnen\n" +
" grid: {\n" +
" color: \"rgba(255, 255, 255, 0.1)\", // Farbe der Gitterlinien\n" +
" },\n" +
" ticks: {\n" +
" fontColor: \"#ccc\", // Farbe der Achsenbeschriftungen\n" +
" },\n" +
" },\n" +
" x: {\n" +
" grid: {\n" +
" display: false, // Gitterlinien auf der x-Achse ausblenden\n" +
" },\n" +
" ticks: {\n" +
" fontColor: \"#ccc\", // Farbe der Achsenbeschriftungen\n" +
" },\n" +
" },\n" +
" },\n" +
" plugins: {\n" +
" legend: {\n" +
" labels: {\n" +
" color: \"#ccc\", // Farbe der Legendenbeschriftungen\n" +
" },\n" +
" },\n" +
" },\n" +
" },\n" +
" });\n" +
" getDiscordUserCounts();\n" +
"\n" +
" // Funktion zum Abrufen der Nutzerzahlen\n" +
" function getDiscordUserCounts() {\n" +
" // Hier kannst du den Code zur Kommunikation mit der Discord-API und zum Abrufen der Nutzerzahlen einfügen\n" +
" // Verwende geeignete Bibliotheken oder Frameworks, um dies zu erreichen\n" +
" // Aktualisiere dann das Diagramm mit den abgerufenen Nutzerzahlen\n" +
" \n" +
" var months = [\"Heute\", \"Gestern\", \"Vorgestern\", \"vor 4 Tagen\", \"vor 5 Tagen\", \"vor 6 Tagen\", \"vor 7 Tagen\"];\n" +
" var months1 = [\"Heute\", \"Gestern\", \"Vorgestern\", \"vor 4 Tagen\", \"vor 5 Tagen\", \"vor 6 Tagen\", \"vor 7 Tagen\"];\n" +
" var months2 = [\"Heute\", \"Gestern\", \"Vorgestern\", \"vor 4 Tagen\", \"vor 5 Tagen\", \"vor 6 Tagen\", \"vor 7 Tagen\"];\n" +
" var months3 = [\"Heute\", \"Gestern\", \"Vorgestern\", \"vor 4 Tagen\", \"vor 5 Tagen\", \"vor 6 Tagen\", \"vor 7 Tagen\"];\n" +
"\n" +
" var userCounts = " + Arrays.toString(memberCountForLast7Days) + ";\n" +
" var messageCounts = " + Arrays.toString(messageCountFromTheLast7Days) + ";\n" +
" var voicechanneldurationvalues = " + Arrays.toString(voicechanneltotaldurationinminutescount) + ";\n" +
" var voicechannelmaxusercount = " + Arrays.toString(voicetopusercount) + ";\n" +
"\n" +
" userChart.data.labels = months;\n" +
" userChart.data.datasets[0].data = userCounts;\n" +
" userChart.update();\n" +
"\n" +
" messageChartObj.data.labels = months1;\n" +
" messageChartObj.data.datasets[0].data = messageCounts;\n" +
" messageChartObj.update();\n" +
"\n" +
" voicechanneltalkdurationobj.data.labels = months2;\n" +
" voicechanneltalkdurationobj.data.datasets[0].data = voicechanneldurationvalues;\n" +
" voicechanneltalkdurationobj.update();\n" +
"\n" +
" voicechannelusercountobj.data.labels = months3;\n" +
" voicechannelusercountobj.data.datasets[0].data = voicechannelmaxusercount;\n" +
" voicechannelusercountobj.update();\n" +
"\n" +
" }\n" +
" window.addEventListener(\"resize\", function() {\n" +
" userChart.resize();\n" +
" messageChartObj.resize();\n" +
" });\n" +
"</script>\n" +
"</body>\n" +
"</html>"
);
return html.toString();
} catch (Exception e) {
errortriggercode.sendERROR(e.toString(), "messageAndUserCountLog.java");
return "ERROR";
}
}
private static int[] getMemberCountForLast7Days(String guildId, Connection connection) throws SQLException {
LocalDate currentDate = LocalDate.now();
LocalDate sevenDaysAgo = currentDate.minusDays(7);
String selectSql = "SELECT date, membercount FROM member_counts WHERE guild_id = ? AND date >= ? AND date <= ?";
PreparedStatement selectStatement = connection.prepareStatement(selectSql);
selectStatement.setString(1, guildId);
selectStatement.setString(2, sevenDaysAgo.toString());
selectStatement.setString(3, currentDate.toString());
ResultSet resultSet = selectStatement.executeQuery();
Map<String, Integer> memberCountMap = new HashMap<>();
while (resultSet.next()) {
String date = resultSet.getString("date");
int memberCount = resultSet.getInt("membercount");
memberCountMap.put(date, memberCount);
}
int[] memberCountArray = new int[7];
for (int i = 0; i < 7; i++) {
LocalDate date = currentDate.minusDays(i);
String dateString = date.toString();
memberCountArray[i] = memberCountMap.getOrDefault(dateString, 0);
}
return memberCountArray;
}
public static int[] getMessageCountForLast7Days(Connection connection) throws SQLException {
int[] messageCountArray = new int[7];
LocalDate currentDate = LocalDate.now();
for (int i = 0; i < 7; i++) {
LocalDate date = currentDate.minusDays(i);
String dateString = date.toString();
int messageCount = getMessageCountFromDiscord(dateString, connection);
messageCountArray[i] = messageCount;
}
return messageCountArray;
}
public static int[] getVoteCount(Connection connection) throws SQLException {
int[] VoteCount = new int[7];
LocalDate currentDate = LocalDate.now();
for (int i = 0; i < 7; i++) {
LocalDate date = currentDate.minusDays(i);
String dateString = date.toString();
int messageCount = getVoteCounts(dateString, connection);
VoteCount[i] = messageCount;
}
return VoteCount;
}
public static int[] getTopVoiceUserCountForLast7Days(Connection connection) throws SQLException {
int[] userCountArray = new int[7];
LocalDate currentDate = LocalDate.now();
for (int i = 0; i < 7; i++) {
LocalDate date = currentDate.minusDays(i);
String dateString = date.toString();
int userCount = getFinalVoiceChannelTopUserCount(dateString, connection);
userCountArray[i] = userCount;
}
return userCountArray;
}
private static int getMessageCountFromDiscord(String dateString, Connection connection) throws SQLException {
int count = 0;
String selectSql = "SELECT messagecount FROM message_counts WHERE date = ?";
PreparedStatement selectStatement = connection.prepareStatement(selectSql);
selectStatement.setString(1, dateString);
ResultSet resultSet = selectStatement.executeQuery();
if (resultSet.next()) {
count = resultSet.getInt("messagecount");
}
return count;
}
private static int getVoteCounts(String dateString, Connection connection) throws SQLException {
int count = 0;
String selectSql = "SELECT votecount FROM vote_count WHERE date = ?";
PreparedStatement selectStatement = connection.prepareStatement(selectSql);
selectStatement.setString(1, dateString);
ResultSet resultSet = selectStatement.executeQuery();
if (resultSet.next()) {
count = resultSet.getInt("votecount");
}
return count;
}
private static int getFinalVoiceChannelTopUserCount(String dateString, Connection connection) throws SQLException {
int count = 0;
String selectSql = "SELECT count FROM top_user_count WHERE date = ?";
PreparedStatement selectStatement = connection.prepareStatement(selectSql);
selectStatement.setString(1, dateString);
ResultSet resultSet = selectStatement.executeQuery();
if (resultSet.next()) {
count = resultSet.getInt("count");
}
return count;
}
public static String[] getTopUserIds() {
String[] topUserIds = new String[7];
try {
String selectSql = "SELECT member_id FROM message_counts_for_every_user ORDER BY message_count DESC LIMIT 7";
PreparedStatement selectStatement = Hauptklasse.connNormal.prepareStatement(selectSql);
ResultSet resultSet = selectStatement.executeQuery();
int i = 0;
while (resultSet.next()) {
String userId = resultSet.getString("member_id");
topUserIds[i] = userId;
i++;
}
} catch (SQLException e) {
errortriggercode.sendERROR(e.toString(), "messageAndUserCountLog.java");
}
return topUserIds;
}
public static int[] getMessageCountsForTopUsers(Connection connection, String[] memberIds) throws SQLException {
int[] messageCounts = new int[memberIds.length];
String selectSql = "SELECT message_count FROM message_counts_for_every_user WHERE member_id = ?";
PreparedStatement selectStatement = connection.prepareStatement(selectSql);
for (int i = 0; i < memberIds.length; i++) {
selectStatement.setString(1, memberIds[i]);
ResultSet resultSet = selectStatement.executeQuery();
if (resultSet.next()) {
messageCounts[i] = resultSet.getInt("message_count");
} else {
messageCounts[i] = 0;
}
}
return messageCounts;
}
public static String[] getAvatarAndTag(String memberId) {
String[] AvatarAndTag = new String[2];
try {
String selectSql = "SELECT tag, avatar_url FROM message_counts_for_every_user WHERE member_id = ?";
PreparedStatement selectStatement = Hauptklasse.connNormal.prepareStatement(selectSql);
selectStatement.setString(1, memberId);
ResultSet resultSet = selectStatement.executeQuery();
if (resultSet.next()) {
String tag = resultSet.getString("tag");
String avatarUrl = resultSet.getString("avatar_url");
AvatarAndTag[0] = tag;
AvatarAndTag[1] = avatarUrl;
} else {
System.out.println("Keine Daten gefunden für das angegebene Mitglied.");
}
} catch (SQLException e) {
errortriggercode.sendERROR(e.toString(), "messageAndUserCountLog.java");
}
return AvatarAndTag;
}
}
So something must be blocking the WS thread here, make a thread dump for it, using your ide, or with jstack -l <pid>
, get the pid with jps -l
can you please explain this in more detail i don't quite understand it 🤣
can you please explain this in more detail i don't quite understand it 🤣
Make the thread dump (see https://jda.wiki/introduction/faq/), then send it here, you most likely have to look at the Main WS-ReadThread
or something named similarly
before i post this is there any sensitive information in it?
no, but heap dumps do
Here is the MainWS-ReadThread
"JDA MainWS-ReadThread" #43 prio=5 os_prio=0 cpu=109.38ms elapsed=44.11s tid=0x000001757fd34800 nid=0xe1f8 waiting on condition [0x0000004f773fe000] java.lang.Thread.State: WAITING (parking) at jdk.internal.misc.Unsafe.park(java.base@11.0.18/Native Method)
As you can see, you can't use awaitReady
in a listener, as you prevent JDA from receiving more data, which would then make the shard ready.
Waiting in the WS thread makes a deadlock as no data can be received anymore, and also creates that timeout error
Now it works thank you so much.
is there a way to disable these annoying messages once we are in
SLF4J(W): No SLF4J providers were found. SLF4J(W): Defaulting to no-operation (NOP) logger implementation SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details. 2024-07-18 12:23:28 [JDALogger] [WARN] Using fallback logger due to missing SLF4J implementation. 2024-07-18 12:23:28 [JDALogger] [WARN] Please setup a logging framework to use JDA. 2024-07-18 12:23:28 [JDALogger] [WARN] You can use our logging setup guide https://jda.wiki/setup/logging/ 2024-07-18 12:23:28 [JDALogger] [WARN] To disable the fallback logger, add the slf4j-nop dependency or use JDALogger.setFallbackLoggerEnabled(false) 2024-07-18 12:23:29 [JDA] [INFO] Login Successful!
These are logs, not annoying messages, quite the opposite in fact, also have you seen the jda.wiki
link
yes but it is possible to deactivate them i did that with another bot
yes but it is possible to deactivate them i did that with another bot
I don't recommend disabling them at all. Logging is done for a reason, not to annoy you.
You can lower the log level to have less messages, see the configuration file.
ich want the log level ERROR
how do i do that
ok
General Troubleshooting
Version of JDA
5.0.1
Expected Behaviour
it is expected that there will be no errors
Code Example for Reproduction Steps
Code for JDABuilder or DefaultShardManagerBuilder used
Exception or Error