aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPinapelz <donaldshan1@outlook.com>2023-04-13 14:27:37 -0700
committerPinapelz <donaldshan1@outlook.com>2023-04-13 14:27:37 -0700
commit0fc9cf5fb7c9113ef8c61b3df4adfd4cdbb5511e (patch)
tree9046a3a7be4ed66082cf7fe6859a35afd8abb169
parent22fe876197002465ea2e2a8952a3dccf389276f8 (diff)
Fixed bug where Channel Feed was not being cleared for hours
Channels were not being cleared if a channel did not have a specific update (i.e new upcoming or currently live) leaving old streams in feed for hours
-rw-r--r--src/main/java/Main.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
index 78a2f4d..6fdaf1e 100644
--- a/src/main/java/Main.java
+++ b/src/main/java/Main.java
@@ -30,12 +30,9 @@ public class Main extends ListenerAdapter{
commandManager = new CommandManager(fileDataProcessor.readCredential("holodexAPIKey"));
jdaBuilder = JDABuilder.createDefault(fileDataProcessor.readCredential("discordToken"));
jdaBuilder.addEventListeners(commandManager);
+ jdaBuilder.addEventListeners(this);
try {
jda = jdaBuilder.build();
- statusHandler = new StatusHandler(jda);
- statusHandler.updateSlashCommands();
- System.out.println("Bot is ready!");
- initializeAutoRefresh();
}
catch (LoginException e) {
System.out.println("Unable to login with the provided token. Please check your token and try again.");
@@ -56,18 +53,19 @@ public class Main extends ListenerAdapter{
}
for (OrgChannelTuple orgChannelTuple : refreshChannels) {
System.out.println("Refreshing " + orgChannelTuple.getType() + " " + orgChannelTuple.getName());
+ jda.getTextChannelById(orgChannelTuple.getDiscordChannelId()).purgeMessages(
+ jda.getTextChannelById(orgChannelTuple.getDiscordChannelId()).getIterableHistory().complete());
List<MessageEmbed> messageEmbeds = commandManager.updateUpcomingChannel(orgChannelTuple.getName(), orgChannelTuple.getType());
if (messageEmbeds.size() == 0) {
continue;
}
- jda.getTextChannelById(orgChannelTuple.getDiscordChannelId()).purgeMessages(
- jda.getTextChannelById(orgChannelTuple.getDiscordChannelId()).getIterableHistory().complete());
for (MessageEmbed messageEmbed : messageEmbeds) {
jda.getTextChannelById(orgChannelTuple.getDiscordChannelId()).sendMessageEmbeds(messageEmbed).queue();
}
}
}
catch(NullPointerException ex){
+ System.out.println(ex);
System.out.println("Channel is empty. Skipping refresh there");
}
catch (Exception e) {
@@ -85,6 +83,15 @@ public class Main extends ListenerAdapter{
String msg = message.getContentDisplay();
}
+
+ @Override
+ public void onReady(net.dv8tion.jda.api.events.ReadyEvent event) {
+ System.out.println("Logged in as " + event.getJDA().getSelfUser().getAsTag());
+ statusHandler = new StatusHandler(jda);
+ statusHandler.updateSlashCommands();
+ initializeAutoRefresh();
+ System.out.println("Bot is ready!");
+ }
public static void main(String args[]) {
Main main = new Main();
main.initializeBot();
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage