Skip to content

Commit

Permalink
Fix guild and role config
Browse files Browse the repository at this point in the history
  • Loading branch information
Erdragh committed Feb 8, 2025
1 parent 315a57b commit 7faac6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions common/src/main/kotlin/dev/erdragh/astralbot/Bot.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package dev.erdragh.astralbot

import com.mojang.logging.LogUtils
import dev.erdragh.astralbot.listeners.CommandHandlingListener
import dev.erdragh.astralbot.listeners.UserEventListener
import dev.erdragh.astralbot.config.AstralBotConfig
import dev.erdragh.astralbot.handlers.FAQHandler
import dev.erdragh.astralbot.handlers.MinecraftHandler
import dev.erdragh.astralbot.listeners.CommandHandlingListener
import dev.erdragh.astralbot.listeners.UserEventListener
import kotlinx.coroutines.*
import net.dv8tion.jda.api.JDA
import net.dv8tion.jda.api.JDABuilder
Expand All @@ -14,6 +13,7 @@ import net.dv8tion.jda.api.entities.Guild
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel
import net.dv8tion.jda.api.requests.GatewayIntent
import net.minecraft.server.MinecraftServer
import org.slf4j.LoggerFactory
import java.io.File
import java.time.Duration
import java.time.LocalDateTime
Expand All @@ -22,7 +22,7 @@ import kotlin.io.path.absolute
import kotlin.properties.Delegates

const val MODID = "astralbot"
val LOGGER = LogUtils.getLogger()
val LOGGER = LoggerFactory.getLogger(MODID)

private lateinit var startTimestamp: LocalDateTime
var minecraftHandler: MinecraftHandler? = null
Expand Down Expand Up @@ -90,13 +90,15 @@ private fun setupFromJDA(api: JDA) {
LOGGER.warn("Configured Discord Guild (server) ID is not valid.")
return
}
LOGGER.info("Running with Guild '${g.name}' (${g.id})")
val ch = g.getTextChannelById(AstralBotConfig.DISCORD_CHANNEL.get())
if (ch == null) {
LOGGER.warn("Configured Discord channel ID is not valid.")
return
}
textChannel = ch
guild = g
LOGGER.info("Chat sync configured in channel '${ch.name}' (${ch.id})")

// Text channel was fetched, now the minecraftHandler can fetch its webhook stuff
minecraftHandler?.updateWebhookClient()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ object AstralBotConfig {
DISCORD_CHANNEL = builder.comment("Channel ID where the chat messages are synced")
.defineInRange("discordChannel", 0L, 0L, Long.MAX_VALUE)
DISCORD_GUILD = builder.comment("Guild (server) ID where the chat messages etc. are synced")
.defineInRange("discordChannel", 0L, 0L, Long.MAX_VALUE)
.defineInRange("discordGuild", 0L, 0L, Long.MAX_VALUE)
DISCORD_ROLE = builder.comment("ID of the role given to linked users")
.defineInRange("discordChannel", 0L, 0L, Long.MAX_VALUE)
.defineInRange("discordRole", 0L, 0L, Long.MAX_VALUE)

CLICKABLE_MESSAGES =
builder.comment("Whether to make messages sent into the Minecraft chat open the Discord chat when clicked")
Expand Down

0 comments on commit 7faac6c

Please sign in to comment.