feat: removed old Feature interface, removed manager temp, moved IFeature into .feature.component
chore: add credits, add comments Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
15d2aec85e
commit
e0228c65cd
5 changed files with 22 additions and 42 deletions
|
@ -26,7 +26,9 @@ import dev.kord.core.event.interaction.ButtonInteractionCreateEvent
|
|||
import dev.kord.core.on
|
||||
import dev.kord.gateway.Intent
|
||||
import dev.kord.gateway.PrivilegedIntent
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import net.moonleay.botendo.build.BuildConstants
|
||||
import net.moonleay.lilJudd.buttons.component.EditButtonManager
|
||||
|
@ -35,6 +37,7 @@ import net.moonleay.lilJudd.data.DB
|
|||
import net.moonleay.lilJudd.extensions.FeatureManageExtension
|
||||
import net.moonleay.lilJudd.extensions.SendPlannerExtension
|
||||
import net.moonleay.lilJudd.extensions.VersionExtension
|
||||
import net.moonleay.lilJudd.features.AvailabilityManager
|
||||
import net.moonleay.lilJudd.features.TimeManager
|
||||
import net.moonleay.lilJudd.util.Logger
|
||||
import net.moonleay.lilJudd.util.MessageUtil
|
||||
|
@ -73,11 +76,18 @@ object Bot {
|
|||
CredentialManager.dbPassword
|
||||
)
|
||||
|
||||
// Register the TimePlanner thread
|
||||
val coroutineJob = GlobalScope.launch {
|
||||
TimeManager.registerThread()
|
||||
//PlanningNotifier.registerThread()
|
||||
// Register all the jobs
|
||||
jobs.addAll(
|
||||
listOf(
|
||||
TimeManager,
|
||||
AvailabilityManager,
|
||||
).map {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
it.registerThread()
|
||||
}
|
||||
}
|
||||
)
|
||||
// Thanks silenium-dev <3
|
||||
|
||||
// Add bot token to kord
|
||||
bot = ExtensibleBot(CredentialManager.token) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData
|
|||
import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData
|
||||
import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles
|
||||
import net.moonleay.lilJudd.data.tables.TimePlanningMessages
|
||||
import net.moonleay.lilJudd.features.component.IFeature
|
||||
import net.moonleay.lilJudd.util.EmbedUtil
|
||||
import net.moonleay.lilJudd.util.Logger
|
||||
import net.moonleay.lilJudd.util.TimeUtil
|
||||
|
@ -136,11 +137,10 @@ object AvailabilityManager : IFeature {
|
|||
|
||||
override suspend fun registerThread() {
|
||||
Logger.out("Adding availability scheduler...")
|
||||
val scheduler = buildSchedule("0 0 5 * * * 0o *w") // 0 0 4 * * * 0o 1w // 0o is UTC
|
||||
val scheduler = buildSchedule("0 0 5 * * * 0o *") // 0 0 4 * * * 0o 1w // 0o is UTC
|
||||
scheduler.doInfinity {
|
||||
|
||||
Logger.out("Starting to update roles...")
|
||||
this.runThread()
|
||||
}
|
||||
Logger.out("Starting to update roles...")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData
|
|||
import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles
|
||||
import net.moonleay.lilJudd.data.tables.TimePlanningChannels
|
||||
import net.moonleay.lilJudd.data.tables.TimePlanningMessages
|
||||
import net.moonleay.lilJudd.features.component.IFeature
|
||||
import net.moonleay.lilJudd.util.EmbedUtil
|
||||
import net.moonleay.lilJudd.util.Logger
|
||||
import net.moonleay.lilJudd.util.MessageUtil
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* lilJudd
|
||||
* Copyright (C) 2023 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.features.component
|
||||
|
||||
import dev.kord.core.entity.Message
|
||||
|
||||
interface Feature {
|
||||
val feature: FeatureEnum
|
||||
|
||||
fun enable(): Message
|
||||
fun disable(): Message
|
||||
|
||||
suspend fun registerThread()
|
||||
}
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package net.moonleay.lilJudd.features.component
|
||||
|
||||
object FeatureManager {
|
||||
// See note in Feature.kt
|
||||
val features = mutableListOf<Feature>()
|
||||
interface IFeature {
|
||||
suspend fun registerThread()
|
||||
}
|
Loading…
Reference in a new issue