Skip to content

Commit

Permalink
fix: load knowledgebase & help posts asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbker committed Feb 17, 2024
1 parent accf95e commit bd61acf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ package com.learnspigot.bot.help.search

import com.learnspigot.bot.Server
import com.learnspigot.bot.util.PostRegistry
import java.util.concurrent.CompletableFuture
import java.util.concurrent.Executors

class HelpPostRegistry : PostRegistry() {

init {
// Get open help posts
Server.helpChannel.threadChannels.forEach { posts[it.name] = it.id }
// Get closed help posts
Server.helpChannel.retrieveArchivedPublicThreadChannels().forEach { posts[it.name] = it.id }
CompletableFuture.runAsync({
// Get open help posts
Server.helpChannel.threadChannels.forEach { posts[it.name] = it.id }
// Get closed help posts
Server.helpChannel.retrieveArchivedPublicThreadChannels().forEach { posts[it.name] = it.id }
}, Executors.newCachedThreadPool())
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ package com.learnspigot.bot.knowledgebase

import com.learnspigot.bot.Server
import com.learnspigot.bot.util.PostRegistry
import java.util.concurrent.CompletableFuture
import java.util.concurrent.Executors

class KnowledgebasePostRegistry : PostRegistry() {

init {
Server.knowledgebaseChannel.threadChannels.forEach {
posts[it.name] = it.id
}
CompletableFuture.runAsync({
Server.knowledgebaseChannel.threadChannels.forEach {
posts[it.name] = it.id
}
}, Executors.newCachedThreadPool())
}

}

0 comments on commit bd61acf

Please sign in to comment.