Skip to content
This repository was archived by the owner on Jun 20, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/kotlin/wtf/votebot/bot/Launcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import wtf.votebot.bot.config.ConfigLoader
import wtf.votebot.bot.config.backend.EnvBackend
import wtf.votebot.bot.config.backend.VaultBackend
import wtf.votebot.bot.core.ServiceRegistry
import wtf.votebot.bot.core.VoteBot
import wtf.votebot.bot.core.module
import kotlin.system.exitProcess

Expand Down Expand Up @@ -83,6 +84,8 @@ fun main(args: Array<String>) {
if (!config.isDevelopment() || cli.hasOption("FSR")) {
ServiceRegistry(ApplicationInfo.SERVICE_NAME, config.httpPort)
}

VoteBot(config)
}

private fun parseCliOptions(args: Array<String>): CommandLine {
Expand Down
9 changes: 9 additions & 0 deletions src/main/kotlin/wtf/votebot/bot/core/VoteBot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,22 @@

package wtf.votebot.bot.core

import discord4j.core.DiscordClient
import discord4j.core.DiscordClientBuilder
import discord4j.core.`object`.presence.Presence
import discord4j.core.shard.ShardingClientBuilder
import wtf.votebot.bot.config.Config

/**
* The bots actual main class.
*/
class VoteBot(private val config: Config) {
init {
ShardingClientBuilder(config.discordToken!!).build()
.map { it.setInitialPresence(Presence.invisible()) }
.map(DiscordClientBuilder::build)
.flatMap(DiscordClient::login)
.blockLast()
Runtime.getRuntime().addShutdownHook(Thread(this::shutdown))
}

Expand Down