Skip to content

Commit

Permalink
move channel definitions to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Gutin1 committed Jan 4, 2024
1 parent 03188b4 commit 043fddb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.horizonsend.ion.common.utils.discord

enum class Channel(val id: Long) {
GLOBAL(1060343929473601536),
EVENTS(1070622772180566116),
CHANGELOG(1182158653743173632)
enum class Channel {
GLOBAL,
EVENTS,
CHANGELOG,
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package net.horizonsend.ion.discord.configuration

import kotlinx.serialization.Serializable
import net.horizonsend.ion.common.utils.discord.Channel

@Serializable
data class DiscordConfiguration(
val discordBotToken: String = "",
val guildID: Long = 0,
val globalChannelId: Long = 0
val globalChannelId: Long = 0,
val channelIdMap: Map<Channel, Long> = mapOf(
Channel.GLOBAL to 954781227246817341,
Channel.EVENTS to 979124611256041473,
Channel.CHANGELOG to 1096907580577697833
)
)

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package net.horizonsend.ion.discord.utils
import net.dv8tion.jda.api.entities.Guild
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel
import net.horizonsend.ion.common.utils.discord.Channel
import net.horizonsend.ion.discord.IonDiscordBot
import net.horizonsend.ion.discord.IonDiscordBot.exit

fun Channel.getID() = IonDiscordBot.configuration.channelIdMap[this]!!

fun Channel.getChannel(guild: Guild): TextChannel {
return guild.getTextChannelById(id) ?: exit("Could not find channel $name", NullPointerException())
return guild.getTextChannelById(getID()) ?: exit("Could not find channel $name", NullPointerException())
}

0 comments on commit 043fddb

Please sign in to comment.