From 894e03c9c6dda206863084204762b6769e56f37c Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 18 Jan 2024 18:35:17 +0100 Subject: [PATCH] feat!: updated rest of the code to use new API system Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/Bot.kt | 10 ++-------- .../jobs/Splatoon3ApiScheduleUpdateScheduler.kt | 10 ++++------ .../net/moonleay/lilJudd/jobs/StatusUpdater.kt | 14 +++++++------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt index fcdc5e6..8282212 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt @@ -32,9 +32,7 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.launch import net.moonleay.lilJudd.buttons.component.EditButtonManager import net.moonleay.lilJudd.data.CredentialManager -import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3ApiCache -import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiDataType -import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiRequestType +import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3Api import net.moonleay.lilJudd.data.database.DB import net.moonleay.lilJudd.extensions.* import net.moonleay.lilJudd.features.AvailabilityManager @@ -173,7 +171,7 @@ object Bot { } // Update the Splatoon 3 api data and make sure it stays up-to-date - Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_CREATION_AT_STARTUP) + Splatoon3Api.updateSchedule() JobManager.addJob(Splatoon3ApiScheduleUpdateScheduler) /* Other caches will be added when implemented @@ -183,10 +181,6 @@ object Bot { // Had to disable bc of an error. // Will fix when I have time - - //JobManager.addJob(Splatoon3ApiFestivalAndCoopUpdateScheduler) - //JobManager.addJob(Splatoon3ApiSplatnetGearUpdateScheduler) - //Start the bot bot.start() } diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt index 2a47939..6ec76f9 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt @@ -20,9 +20,7 @@ package net.moonleay.lilJudd.jobs import dev.inmo.krontab.KronScheduler import kotlinx.coroutines.Job -import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3ApiCache -import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiDataType -import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiRequestType +import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3Api import net.moonleay.lilJudd.jobs.component.CronjobType import net.moonleay.lilJudd.jobs.component.ICronjob import net.moonleay.lilJudd.util.Logger @@ -40,8 +38,8 @@ object Splatoon3ApiScheduleUpdateScheduler : ICronjob { override lateinit var scheduler: KronScheduler override suspend fun jobFunction() { - Logger.out("Running Splatoon3ApiScheduleUpdateScheduler.") - Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_UPDATE) - Logger.out("Splatoon3ApiScheduleUpdateScheduler finished.") + Logger.out("Updating Schedules...") + Splatoon3Api.updateSchedule() + Logger.out("Updating finished.") } } diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt index 762b498..4aa8fb3 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt @@ -1,6 +1,6 @@ /* * lilJudd - * Copyright (C) 2023 moonleay + * Copyright (C) 2024 moonleay * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ import dev.inmo.krontab.KronScheduler import dev.kord.common.entity.PresenceStatus import kotlinx.coroutines.Job import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.data.api.Splatoon3Api +import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3ApiDataGrabber import net.moonleay.lilJudd.jobs.component.CronjobType import net.moonleay.lilJudd.jobs.component.ICronjob @@ -56,11 +56,11 @@ object StatusUpdater : ICronjob { private fun refreshStatusList(timestamp: Long) { statusList = listOf( - Splatoon3Api.getRotationTime(timestamp), - Splatoon3Api.getRegularMapsFormatted(timestamp), - Splatoon3Api.getOpenMapFormatted(timestamp), - Splatoon3Api.getSeriesMapsFormatted(timestamp), - Splatoon3Api.getXMapFormatted(timestamp) + Splatoon3ApiDataGrabber.getRotationTime(timestamp), + Splatoon3ApiDataGrabber.getRegularMapsFormatted(timestamp), + Splatoon3ApiDataGrabber.getOpenMapFormatted(timestamp), + Splatoon3ApiDataGrabber.getSeriesMapsFormatted(timestamp), + Splatoon3ApiDataGrabber.getXMapFormatted(timestamp) ) } }