|
|
|
@ -2,6 +2,8 @@ package xyz.brettb.discord.ieeevents |
|
|
|
|
|
|
|
import ch.qos.logback.classic.Level |
|
|
|
import ch.qos.logback.classic.Logger |
|
|
|
import com.mongodb.client.MongoClient |
|
|
|
import com.mongodb.client.MongoDatabase |
|
|
|
import com.sksamuel.hoplite.ConfigLoader |
|
|
|
import net.dv8tion.jda.api.JDA |
|
|
|
import net.dv8tion.jda.api.JDABuilder |
|
|
|
@ -20,6 +22,7 @@ import net.fortuna.ical4j.model.Date |
|
|
|
import net.fortuna.ical4j.model.DateTime |
|
|
|
import net.fortuna.ical4j.model.Period |
|
|
|
import net.fortuna.ical4j.model.component.VEvent |
|
|
|
import org.litote.kmongo.KMongo |
|
|
|
import org.reflections.Reflections |
|
|
|
import org.slf4j.LoggerFactory |
|
|
|
import tech.junodevs.discord.kriess.impl.managers.CommandManager |
|
|
|
@ -95,10 +98,20 @@ object IEEEventsBot : EventListener { |
|
|
|
lateinit var commandManager: CommandManager<IEEEventsGuildSettings> |
|
|
|
|
|
|
|
/** |
|
|
|
* The bot [config]uration |
|
|
|
* The bot [config] |
|
|
|
*/ |
|
|
|
lateinit var config: BotConfig |
|
|
|
|
|
|
|
/** |
|
|
|
* The [MongoClient] used by the bot |
|
|
|
*/ |
|
|
|
lateinit var dbClient: MongoClient |
|
|
|
|
|
|
|
/** |
|
|
|
* The [MongoDatabase] used by the bot |
|
|
|
*/ |
|
|
|
lateinit var database: MongoDatabase |
|
|
|
|
|
|
|
/** |
|
|
|
* The iCal [Calendar] object gotten from the [BotConfig.calendarUrl]. |
|
|
|
*/ |
|
|
|
@ -176,9 +189,14 @@ object IEEEventsBot : EventListener { |
|
|
|
|
|
|
|
config = ConfigLoader().loadConfigOrThrow(configFile) |
|
|
|
|
|
|
|
// Loger |
|
|
|
val level = Level.toLevel(config.logLevel, Level.INFO) |
|
|
|
(LoggerFactory.getLogger("ROOT") as Logger).level = level |
|
|
|
|
|
|
|
// Database |
|
|
|
dbClient = KMongo.createClient(config.database.url) |
|
|
|
database = dbClient.getDatabase(config.database.name) |
|
|
|
|
|
|
|
// Managers |
|
|
|
IEEEventsGuildSettingsManager.start() |
|
|
|
commandManager = CommandManager(IEEEventsGuildSettingsManager, config.prefix) { cEvent, t -> |
|
|
|
|