This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package wtf.beatrice.hidekobot.runnables;
|
||||
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import wtf.beatrice.hidekobot.Configuration;
|
||||
import wtf.beatrice.hidekobot.Cache;
|
||||
import wtf.beatrice.hidekobot.HidekoBot;
|
||||
import wtf.beatrice.hidekobot.utils.Logger;
|
||||
|
||||
@@ -16,10 +16,10 @@ public class CommandsUpdateTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(Configuration.isVerbose()) logger.log("Refreshing commands cache...");
|
||||
if(Cache.isVerbose()) logger.log("Refreshing commands cache...");
|
||||
JDA instance = HidekoBot.getAPI();
|
||||
if(instance == null) return;
|
||||
Configuration.setRegisteredCommands(instance.retrieveCommands().complete());
|
||||
if(Configuration.isVerbose()) logger.log("Commands cache refreshed!");
|
||||
Cache.setRegisteredCommands(instance.retrieveCommands().complete());
|
||||
if(Cache.isVerbose()) logger.log("Commands cache refreshed!");
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.components.LayoutComponent;
|
||||
import net.dv8tion.jda.api.requests.RestAction;
|
||||
import wtf.beatrice.hidekobot.Configuration;
|
||||
import wtf.beatrice.hidekobot.Cache;
|
||||
import wtf.beatrice.hidekobot.HidekoBot;
|
||||
import wtf.beatrice.hidekobot.database.DatabaseManager;
|
||||
import wtf.beatrice.hidekobot.utils.Logger;
|
||||
@@ -26,9 +26,9 @@ public class ExpiredMessageTask implements Runnable {
|
||||
|
||||
public ExpiredMessageTask()
|
||||
{
|
||||
String format = Configuration.getExpiryTimestampFormat();
|
||||
String format = Cache.getExpiryTimestampFormat();
|
||||
formatter = DateTimeFormatter.ofPattern(format);
|
||||
databaseManager = Configuration.getDatabaseManager();
|
||||
databaseManager = Cache.getDatabaseManager();
|
||||
logger = new Logger(getClass());
|
||||
}
|
||||
|
||||
@@ -36,10 +36,10 @@ public class ExpiredMessageTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
databaseManager = Configuration.getDatabaseManager();
|
||||
databaseManager = Cache.getDatabaseManager();
|
||||
if(databaseManager == null) return;
|
||||
|
||||
List<String> expiringMessages = Configuration.getDatabaseManager().getQueuedExpiringMessages();
|
||||
List<String> expiringMessages = Cache.getDatabaseManager().getQueuedExpiringMessages();
|
||||
if(expiringMessages == null || expiringMessages.isEmpty()) return;
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
@@ -47,7 +47,7 @@ public class ExpiredMessageTask implements Runnable {
|
||||
for(String messageId : expiringMessages)
|
||||
{
|
||||
|
||||
if(Configuration.isVerbose()) logger.log("expired check: " + messageId);
|
||||
if(Cache.isVerbose()) logger.log("expired check: " + messageId);
|
||||
|
||||
String expiryTimestamp = databaseManager.getQueuedExpiringMessageExpiryDate(messageId);
|
||||
if(expiryTimestamp == null || expiryTimestamp.equals("")) // if missing timestamp
|
||||
@@ -62,7 +62,7 @@ public class ExpiredMessageTask implements Runnable {
|
||||
LocalDateTime expiryDate = LocalDateTime.parse(expiryTimestamp, formatter);
|
||||
if(now.isAfter(expiryDate))
|
||||
{
|
||||
if(Configuration.isVerbose()) logger.log("expired: " + messageId);
|
||||
if(Cache.isVerbose()) logger.log("expired: " + messageId);
|
||||
disableExpired(messageId);
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class ExpiredMessageTask implements Runnable {
|
||||
RestAction<Message> retrieveAction = textChannel.retrieveMessageById(messageId);
|
||||
|
||||
|
||||
if(Configuration.isVerbose()) logger.log("cleaning up: " + messageId);
|
||||
if(Cache.isVerbose()) logger.log("cleaning up: " + messageId);
|
||||
|
||||
retrieveAction.queue(
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package wtf.beatrice.hidekobot.runnables;
|
||||
|
||||
import wtf.beatrice.hidekobot.Configuration;
|
||||
import wtf.beatrice.hidekobot.Cache;
|
||||
import wtf.beatrice.hidekobot.utils.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -21,10 +21,10 @@ public class HeartBeatTask implements Runnable
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
String apiKey = Configuration.getHeartBeatApiKey();
|
||||
String apiKey = Cache.getHeartBeatApiKey();
|
||||
if(apiKey == null || apiKey.isEmpty()) return;
|
||||
|
||||
String urlString = Configuration.getFullHeartBeatLink();
|
||||
String urlString = Cache.getFullHeartBeatLink();
|
||||
try {
|
||||
|
||||
URL heartbeatUrl = new URL(urlString);
|
||||
@@ -38,7 +38,7 @@ public class HeartBeatTask implements Runnable
|
||||
if(200 <= responseCode && responseCode < 300)
|
||||
{
|
||||
// only log ok response codes when verbosity is enabled
|
||||
if(Configuration.isVerbose()) logger.log("Heartbeat response code: " + responseCode);
|
||||
if(Cache.isVerbose()) logger.log("Heartbeat response code: " + responseCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user