chore: code cleanup
Some checks are pending
Build Gradle project / build-gradle-project (push) Waiting to run

Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
moonleay 2024-01-19 10:53:49 +01:00
parent 38d61ae862
commit b65dadd42f
Signed by: moonleay
GPG key ID: 82667543CCD715FB
41 changed files with 97 additions and 101 deletions

View file

@ -34,7 +34,7 @@ import net.moonleay.lilJudd.util.EmbedUtil
import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.Logger
import net.moonleay.lilJudd.util.MessageUtil import net.moonleay.lilJudd.util.MessageUtil
class AcceptEditButton() : IEditButton { class AcceptEditButton : IEditButton {
override val id: String = "public.edit.btn.matchmanagement.accept" override val id: String = "public.edit.btn.matchmanagement.accept"
override suspend fun onInteraction( override suspend fun onInteraction(
@ -60,7 +60,7 @@ class AcceptEditButton() : IEditButton {
Logger.out("role is null") Logger.out("role is null")
return return
} }
val member = interaction.user.asMember(guild.id) ?: return val member = interaction.user.asMember(guild.id)
// do the checks and update // do the checks and update
if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) { if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) {
if (member.roleIds.contains(Snowflake(mpdd.roleID))) { if (member.roleIds.contains(Snowflake(mpdd.roleID))) {

View file

@ -60,7 +60,7 @@ class DeclineEditButton : IEditButton {
Logger.out("role is null") Logger.out("role is null")
return return
} }
val member = interaction.user.asMember(guild.id) ?: return val member = interaction.user.asMember(guild.id)
if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) { if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) {
if (member.roleIds.contains(Snowflake(mpdd.roleID))) { if (member.roleIds.contains(Snowflake(mpdd.roleID))) {
Logger.out("Removing role from ${member.username}") Logger.out("Removing role from ${member.username}")

View file

@ -25,7 +25,7 @@ import net.moonleay.liljudd.build.BuildConstants
object Splatoon3Api { object Splatoon3Api {
var schedules: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.Schedules? = null var schedules: Schedules? = null
fun updateSchedule() { fun updateSchedule() {
val response = NetUtil.GETJsonData("https://splatoon3.ink/data/schedules.json", "lilJudd/${BuildConstants.version}") val response = NetUtil.GETJsonData("https://splatoon3.ink/data/schedules.json", "lilJudd/${BuildConstants.version}")

View file

@ -24,7 +24,7 @@ import net.moonleay.lilJudd.data.api.splatoon3ink.schedules.XNode
import net.moonleay.lilJudd.util.TimeUtil import net.moonleay.lilJudd.util.TimeUtil
object Splatoon3ApiDataGrabber { object Splatoon3ApiDataGrabber {
private fun getRegularMode(timestamp: Long): net.moonleay.lilJudd.data.api.splatoon3ink.schedules.RegularNode { private fun getRegularMode(timestamp: Long): RegularNode {
Splatoon3Api.schedules!!.data.regularSchedules.nodes.map { modeData -> Splatoon3Api.schedules!!.data.regularSchedules.nodes.map { modeData ->
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
@ -35,7 +35,7 @@ object Splatoon3ApiDataGrabber {
throw Exception("No current mode found") throw Exception("No current mode found")
} }
private fun getOpenMode(timestamp: Long): net.moonleay.lilJudd.data.api.splatoon3ink.schedules.BankaraNode { private fun getOpenMode(timestamp: Long): BankaraNode {
Splatoon3Api.schedules!!.data.bankaraSchedules.nodes.map { modeData -> Splatoon3Api.schedules!!.data.bankaraSchedules.nodes.map { modeData ->
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
@ -49,7 +49,7 @@ object Splatoon3ApiDataGrabber {
throw Exception("No current mode found") throw Exception("No current mode found")
} }
private fun getXMode(timestamp: Long): net.moonleay.lilJudd.data.api.splatoon3ink.schedules.XNode { private fun getXMode(timestamp: Long): XNode {
Splatoon3Api.schedules!!.data.xSchedules.nodes.map { modeData -> Splatoon3Api.schedules!!.data.xSchedules.nodes.map { modeData ->
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
@ -60,7 +60,7 @@ object Splatoon3ApiDataGrabber {
throw Exception("No current mode found") throw Exception("No current mode found")
} }
private fun getSeriesMode(timestamp: Long): net.moonleay.lilJudd.data.api.splatoon3ink.schedules.BankaraNode { private fun getSeriesMode(timestamp: Long): BankaraNode {
Splatoon3Api.schedules!!.data.bankaraSchedules.nodes.map { modeData -> Splatoon3Api.schedules!!.data.bankaraSchedules.nodes.map { modeData ->
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")

View file

@ -31,7 +31,7 @@ data class BankaraMatchSetting(
@SerialName("__typename") @SerialName("__typename")
val typename: String, val typename: String,
@SerialName("vsRule") @SerialName("vsRule")
val vsRule: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.VsRule, val vsRule: VsRule,
@SerialName("vsStages") @SerialName("vsStages")
val vsStages: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.VsStage> val vsStages: List<VsStage>
) )

View file

@ -25,11 +25,11 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class BankaraNode( data class BankaraNode(
@SerialName("bankaraMatchSettings") @SerialName("bankaraMatchSettings")
val bankaraMatchSettings: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.BankaraMatchSetting>?, val bankaraMatchSettings: List<BankaraMatchSetting>?,
@SerialName("endTime") @SerialName("endTime")
val endTime: String, val endTime: String,
@SerialName("festMatchSettings") @SerialName("festMatchSettings")
val festMatchSettings: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.FestMatchSettingX>?, val festMatchSettings: List<FestMatchSettingX>?,
@SerialName("startTime") @SerialName("startTime")
val startTime: String val startTime: String
) )

View file

@ -25,5 +25,5 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class BankaraSchedules( data class BankaraSchedules(
@SerialName("nodes") @SerialName("nodes")
val nodes: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.BankaraNode> val nodes: List<BankaraNode>
) )

View file

@ -27,7 +27,7 @@ data class BigRunScheduleNode(
@SerialName("endTime") @SerialName("endTime")
val endTime: String, val endTime: String,
@SerialName("setting") @SerialName("setting")
val setting: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.Setting, val setting: Setting,
@SerialName("__splatoon3ink_king_salmonid_guess") @SerialName("__splatoon3ink_king_salmonid_guess")
val splatoon3inkKingSalmonidGuess: String, val splatoon3inkKingSalmonidGuess: String,
@SerialName("startTime") @SerialName("startTime")

View file

@ -25,5 +25,5 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class BigRunSchedules( data class BigRunSchedules(
@SerialName("nodes") @SerialName("nodes")
val nodes: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.BigRunScheduleNode> val nodes: List<BigRunScheduleNode>
) )

View file

@ -27,9 +27,9 @@ data class CoopGroupingSchedule(
@SerialName("bannerImage") @SerialName("bannerImage")
val bannerImage: String?, // is null val bannerImage: String?, // is null
@SerialName("bigRunSchedules") @SerialName("bigRunSchedules")
val bigRunSchedules: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.BigRunSchedules, val bigRunSchedules: BigRunSchedules,
@SerialName("regularSchedules") @SerialName("regularSchedules")
val regularSchedules: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.RegularSchedules, val regularSchedules: RegularSchedules,
@SerialName("teamContestSchedules") @SerialName("teamContestSchedules")
val teamContestSchedules: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.TeamContestSchedules? val teamContestSchedules: TeamContestSchedules?
) )

View file

@ -27,9 +27,9 @@ data class CoopStage(
@SerialName("id") @SerialName("id")
val id: String, val id: String,
@SerialName("image") @SerialName("image")
val image: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.Image, val image: Image,
@SerialName("name") @SerialName("name")
val name: String, val name: String,
@SerialName("thumbnailImage") @SerialName("thumbnailImage")
val thumbnailImage: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.ThumbnailImage val thumbnailImage: ThumbnailImage
) )

View file

@ -35,9 +35,9 @@ data class CurrentFest(
@SerialName("state") @SerialName("state")
val state: String, val state: String,
@SerialName("teams") @SerialName("teams")
val teams: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.Team>, val teams: List<Team>,
@SerialName("title") @SerialName("title")
val title: String, val title: String,
@SerialName("tricolorStage") @SerialName("tricolorStage")
val tricolorStage: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.TricolorStage val tricolorStage: TricolorStage
) )

View file

@ -25,5 +25,5 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class CurrentPlayer( data class CurrentPlayer(
@SerialName("userIcon") @SerialName("userIcon")
val userIcon: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.UserIcon val userIcon: UserIcon
) )

View file

@ -25,7 +25,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class EventNode( data class EventNode(
@SerialName("leagueMatchSetting") @SerialName("leagueMatchSetting")
val leagueMatchSetting: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.LeagueMatchSetting, val leagueMatchSetting: LeagueMatchSetting,
@SerialName("timePeriods") @SerialName("timePeriods")
val timePeriods: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.TimePeriod> val timePeriods: List<TimePeriod>
) )

View file

@ -25,5 +25,5 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class EventSchedules( data class EventSchedules(
@SerialName("nodes") @SerialName("nodes")
val nodes: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.EventNode> val nodes: List<EventNode>
) )

View file

@ -29,7 +29,7 @@ data class FestMatchSettingX(
@SerialName("__typename") @SerialName("__typename")
val typename: String, val typename: String,
@SerialName("vsRule") @SerialName("vsRule")
val vsRule: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.VsRule, val vsRule: VsRule,
@SerialName("vsStages") @SerialName("vsStages")
val vsStages: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.VsStage> val vsStages: List<VsStage>
) )

View file

@ -27,7 +27,7 @@ data class FestNode(
@SerialName("endTime") @SerialName("endTime")
val endTime: String, val endTime: String,
@SerialName("festMatchSettings") @SerialName("festMatchSettings")
val festMatchSettings: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.FestMatchSettingX?, val festMatchSettings: FestMatchSettingX?,
@SerialName("startTime") @SerialName("startTime")
val startTime: String val startTime: String
) )

View file

@ -25,5 +25,5 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class FestSchedules( data class FestSchedules(
@SerialName("nodes") @SerialName("nodes")
val nodes: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.FestNode> val nodes: List<FestNode>
) )

View file

@ -27,11 +27,11 @@ data class LeagueMatchSetting(
@SerialName("__isVsSetting") @SerialName("__isVsSetting")
val isVsSetting: String, val isVsSetting: String,
@SerialName("leagueMatchEvent") @SerialName("leagueMatchEvent")
val leagueMatchEvent: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.LeagueMatchEvent, val leagueMatchEvent: LeagueMatchEvent,
@SerialName("__typename") @SerialName("__typename")
val typename: String, val typename: String,
@SerialName("vsRule") @SerialName("vsRule")
val vsRule: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.VsRule, val vsRule: VsRule,
@SerialName("vsStages") @SerialName("vsStages")
val vsStages: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.VsStage> val vsStages: List<VsStage>
) )

View file

@ -29,7 +29,7 @@ data class MapNode(
@SerialName("name") @SerialName("name")
val name: String, val name: String,
@SerialName("originalImage") @SerialName("originalImage")
val originalImage: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.OriginalImage, val originalImage: OriginalImage,
@SerialName("stats") @SerialName("stats")
val stats: String?, // is null val stats: String?, // is null
@SerialName("vsStageId") @SerialName("vsStageId")

View file

@ -29,7 +29,7 @@ data class RegularMatchSetting(
@SerialName("__typename") @SerialName("__typename")
val typename: String, val typename: String,
@SerialName("vsRule") @SerialName("vsRule")
val vsRule: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.VsRule, val vsRule: VsRule,
@SerialName("vsStages") @SerialName("vsStages")
val vsStages: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.VsStage> val vsStages: List<VsStage>
) )

View file

@ -27,9 +27,9 @@ data class RegularNode(
@SerialName("endTime") @SerialName("endTime")
val endTime: String, val endTime: String,
@SerialName("festMatchSettings") @SerialName("festMatchSettings")
val festMatchSettings: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.FestMatchSettingXX?, val festMatchSettings: FestMatchSettingXX?,
@SerialName("regularMatchSetting") @SerialName("regularMatchSetting")
val regularMatchSetting: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.RegularMatchSetting, val regularMatchSetting: RegularMatchSetting,
@SerialName("startTime") @SerialName("startTime")
val startTime: String val startTime: String
) )

View file

@ -25,5 +25,5 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class RegularSchedules( data class RegularSchedules(
@SerialName("nodes") @SerialName("nodes")
val nodes: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.BigRunScheduleNode> val nodes: List<BigRunScheduleNode>
) )

View file

@ -25,5 +25,5 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class RegularSchedulesX( data class RegularSchedulesX(
@SerialName("nodes") @SerialName("nodes")
val nodes: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.RegularNode> val nodes: List<RegularNode>
) )

View file

@ -25,5 +25,5 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class Schedules( data class Schedules(
@SerialName("data") @SerialName("data")
val data: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.SchedulesData val data: SchedulesData
) )

View file

@ -25,21 +25,21 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class SchedulesData( data class SchedulesData(
@SerialName("bankaraSchedules") @SerialName("bankaraSchedules")
val bankaraSchedules: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.BankaraSchedules, val bankaraSchedules: BankaraSchedules,
@SerialName("coopGroupingSchedule") @SerialName("coopGroupingSchedule")
val coopGroupingSchedule: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.CoopGroupingSchedule, val coopGroupingSchedule: CoopGroupingSchedule,
@SerialName("currentFest") @SerialName("currentFest")
val currentFest: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.CurrentFest?, val currentFest: CurrentFest?,
@SerialName("currentPlayer") @SerialName("currentPlayer")
val currentPlayer: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.CurrentPlayer, val currentPlayer: CurrentPlayer,
@SerialName("eventSchedules") @SerialName("eventSchedules")
val eventSchedules: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.EventSchedules, val eventSchedules: EventSchedules,
@SerialName("festSchedules") @SerialName("festSchedules")
val festSchedules: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.FestSchedules, val festSchedules: FestSchedules,
@SerialName("regularSchedules") @SerialName("regularSchedules")
val regularSchedules: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.RegularSchedulesX, val regularSchedules: RegularSchedulesX,
@SerialName("vsStages") @SerialName("vsStages")
val vsStages: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.VsStages, val vsStages: VsStages,
@SerialName("xSchedules") @SerialName("xSchedules")
val xSchedules: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.XSchedules val xSchedules: XSchedules
) )

View file

@ -25,13 +25,13 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class Setting( data class Setting(
@SerialName("boss") @SerialName("boss")
val boss: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.Boss, val boss: Boss,
@SerialName("coopStage") @SerialName("coopStage")
val coopStage: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.CoopStage, val coopStage: CoopStage,
@SerialName("__isCoopSetting") @SerialName("__isCoopSetting")
val isCoopSetting: String, val isCoopSetting: String,
@SerialName("__typename") @SerialName("__typename")
val typename: String, val typename: String,
@SerialName("weapons") @SerialName("weapons")
val weapons: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.Weapon> val weapons: List<Weapon>
) )

View file

@ -25,7 +25,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class Team( data class Team(
@SerialName("color") @SerialName("color")
val color: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.Color, val color: Color,
@SerialName("id") @SerialName("id")
val id: String, val id: String,
// @SerialName("myVoteState") // @SerialName("myVoteState")

View file

@ -27,7 +27,7 @@ data class TricolorStage(
@SerialName("id") @SerialName("id")
val id: String, val id: String,
@SerialName("image") @SerialName("image")
val image: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.Image, val image: Image,
@SerialName("name") @SerialName("name")
val name: String val name: String
) )

View file

@ -27,7 +27,7 @@ data class VsStage(
@SerialName("id") @SerialName("id")
val id: String, val id: String,
@SerialName("image") @SerialName("image")
val image: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.Image, val image: Image,
@SerialName("name") @SerialName("name")
val name: String, val name: String,
@SerialName("vsStageId") @SerialName("vsStageId")

View file

@ -25,5 +25,5 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class VsStages( data class VsStages(
@SerialName("nodes") @SerialName("nodes")
val nodes: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.MapNode> val nodes: List<MapNode>
) )

View file

@ -25,7 +25,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class Weapon( data class Weapon(
@SerialName("image") @SerialName("image")
val image: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.Image, val image: Image,
@SerialName("name") @SerialName("name")
val name: String, val name: String,
@SerialName("__splatoon3ink_id") @SerialName("__splatoon3ink_id")

View file

@ -29,7 +29,7 @@ data class XMatchSetting(
@SerialName("__typename") @SerialName("__typename")
val typename: String, val typename: String,
@SerialName("vsRule") @SerialName("vsRule")
val vsRule: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.VsRule, val vsRule: VsRule,
@SerialName("vsStages") @SerialName("vsStages")
val vsStages: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.VsStage> val vsStages: List<VsStage>
) )

View file

@ -27,9 +27,9 @@ data class XNode(
@SerialName("endTime") @SerialName("endTime")
val endTime: String, val endTime: String,
@SerialName("festMatchSettings") @SerialName("festMatchSettings")
val festMatchSettings: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.FestMatchSettingXX?, val festMatchSettings: FestMatchSettingXX?,
@SerialName("startTime") @SerialName("startTime")
val startTime: String, val startTime: String,
@SerialName("xMatchSetting") @SerialName("xMatchSetting")
val xMatchSetting: net.moonleay.lilJudd.data.api.splatoon3ink.schedules.XMatchSetting val xMatchSetting: XMatchSetting
) )

View file

@ -25,5 +25,5 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class XSchedules( data class XSchedules(
@SerialName("nodes") @SerialName("nodes")
val nodes: List<net.moonleay.lilJudd.data.api.splatoon3ink.schedules.XNode> val nodes: List<XNode>
) )

View file

@ -51,7 +51,7 @@ object MatchPlanningDataRepository {
fun get(id: Int): MatchPlanningDataData? = fun get(id: Int): MatchPlanningDataData? =
transaction { transaction {
MatchPlanningData.select { MatchPlanningData.id eq id }.firstOrNull()?.let { MatchPlanningData.selectAll().where { MatchPlanningData.id eq id }.firstOrNull()?.let {
MatchPlanningDataData( MatchPlanningDataData(
it[MatchPlanningData.id], it[MatchPlanningData.id],
it[MatchPlanningData.serverid], it[MatchPlanningData.serverid],
@ -69,7 +69,7 @@ object MatchPlanningDataRepository {
fun getFromMessageInChannelInServer(messageID: Long, channelID: Long, serverID: Long): MatchPlanningDataData? = fun getFromMessageInChannelInServer(messageID: Long, channelID: Long, serverID: Long): MatchPlanningDataData? =
transaction { transaction {
MatchPlanningData.select { MatchPlanningData.selectAll().where {
MatchPlanningData.messageid eq (messageID) and ( MatchPlanningData.messageid eq (messageID) and (
MatchPlanningData.serverid eq (serverID)) and ( MatchPlanningData.serverid eq (serverID)) and (
MatchPlanningData.channelid eq (channelID)) MatchPlanningData.channelid eq (channelID))
@ -98,15 +98,15 @@ object MatchPlanningDataRepository {
fun write(data: MatchPlanningDataData): Int = fun write(data: MatchPlanningDataData): Int =
transaction { transaction {
MatchPlanningData.insert { MatchPlanningData.insert {
it[MatchPlanningData.serverid] = data.serverID it[serverid] = data.serverID
it[MatchPlanningData.channelid] = data.channelID it[channelid] = data.channelID
it[MatchPlanningData.matchtype] = data.matchType it[matchtype] = data.matchType
it[MatchPlanningData.registererid] = data.registererID it[registererid] = data.registererID
it[MatchPlanningData.roleid] = data.roleID it[roleid] = data.roleID
it[MatchPlanningData.opponentName] = data.opponentName it[opponentName] = data.opponentName
it[MatchPlanningData.messageid] = data.messageID it[messageid] = data.messageID
it[MatchPlanningData.timestamp] = data.timestamp it[timestamp] = data.timestamp
it[MatchPlanningData.jobstr] = data.jobString it[jobstr] = data.jobString
} get MatchPlanningData.id } get MatchPlanningData.id
} }
} }

View file

@ -46,9 +46,7 @@ object PlanningNotifierRolesRepository {
fun getForChannel(channelID: Long): PlanningNotifierRolesData? = fun getForChannel(channelID: Long): PlanningNotifierRolesData? =
transaction { transaction {
PlanningNotifierRoles.select { PlanningNotifierRoles.selectAll().where { PlanningNotifierRoles.channelid eq channelID }.firstOrNull()?.let {
PlanningNotifierRoles.channelid eq channelID
}.firstOrNull()?.let {
PlanningNotifierRolesData( PlanningNotifierRolesData(
it[PlanningNotifierRoles.id], it[PlanningNotifierRoles.id],
it[PlanningNotifierRoles.serverid], it[PlanningNotifierRoles.serverid],
@ -61,9 +59,9 @@ object PlanningNotifierRolesRepository {
fun getForChannelInServer(channelID: Long, serverID: Long): PlanningNotifierRolesData? = fun getForChannelInServer(channelID: Long, serverID: Long): PlanningNotifierRolesData? =
transaction { transaction {
PlanningNotifierRoles.select { PlanningNotifierRoles.selectAll()
PlanningNotifierRoles.channelid eq channelID and (PlanningNotifierRoles.serverid eq serverID) .where { PlanningNotifierRoles.channelid eq channelID and (PlanningNotifierRoles.serverid eq serverID) }
}.firstOrNull()?.let { .firstOrNull()?.let {
PlanningNotifierRolesData( PlanningNotifierRolesData(
it[PlanningNotifierRoles.id], it[PlanningNotifierRoles.id],
it[PlanningNotifierRoles.serverid], it[PlanningNotifierRoles.serverid],
@ -76,22 +74,23 @@ object PlanningNotifierRolesRepository {
fun existsInChannel(channelID: Long): Boolean = fun existsInChannel(channelID: Long): Boolean =
transaction { transaction {
PlanningNotifierRoles.select { PlanningNotifierRoles.channelid eq channelID }.count() > 0 PlanningNotifierRoles.selectAll().where { PlanningNotifierRoles.channelid eq channelID }.count() > 0
} }
fun existsInChannelFromSever(channelID: Long, serverID: Long): Boolean = fun existsInChannelFromSever(channelID: Long, serverID: Long): Boolean =
transaction { transaction {
PlanningNotifierRoles.select { PlanningNotifierRoles.channelid eq channelID and (PlanningNotifierRoles.serverid eq serverID) } PlanningNotifierRoles.selectAll()
.where { PlanningNotifierRoles.channelid eq channelID and (PlanningNotifierRoles.serverid eq serverID) }
.count() > 0 .count() > 0
} }
fun write(data: PlanningNotifierRolesData) { fun write(data: PlanningNotifierRolesData) {
transaction { transaction {
PlanningNotifierRoles.insert { PlanningNotifierRoles.insert {
it[PlanningNotifierRoles.serverid] = data.serverID it[serverid] = data.serverID
it[PlanningNotifierRoles.channelid] = data.channelID it[channelid] = data.channelID
it[PlanningNotifierRoles.hastimeroleid] = data.hasTimeRoleID it[hastimeroleid] = data.hasTimeRoleID
it[PlanningNotifierRoles.wantstobenotifiedid] = data.wantsToBeNotifiedID it[wantstobenotifiedid] = data.wantsToBeNotifiedID
} get PlanningNotifierRoles.id } get PlanningNotifierRoles.id
} }
} }

View file

@ -43,7 +43,8 @@ object TimePlanningChannelsRepository {
fun exists(channelID: Long, serverID: Long): Boolean = fun exists(channelID: Long, serverID: Long): Boolean =
transaction { transaction {
TimePlanningChannels.select { TimePlanningChannels.channelid eq channelID and (TimePlanningChannels.serverid eq serverID) } TimePlanningChannels.selectAll()
.where { TimePlanningChannels.channelid eq channelID and (TimePlanningChannels.serverid eq serverID) }
.firstOrNull() != null .firstOrNull() != null
} }
@ -55,15 +56,15 @@ object TimePlanningChannelsRepository {
fun deleteFromChannelInServer(channelID: Long, serverID: Long) { fun deleteFromChannelInServer(channelID: Long, serverID: Long) {
transaction { transaction {
TimePlanningChannels.deleteWhere { TimePlanningChannels.channelid eq channelID and (TimePlanningChannels.serverid eq serverID) } TimePlanningChannels.deleteWhere { channelid eq channelID and (serverid eq serverID) }
} }
} }
fun write(data: TimePlanningChannelsData): Int = fun write(data: TimePlanningChannelsData): Int =
transaction { transaction {
TimePlanningChannels.insert { TimePlanningChannels.insert {
it[TimePlanningChannels.serverid] = data.serverID it[serverid] = data.serverID
it[TimePlanningChannels.channelid] = data.channelID it[channelid] = data.channelID
} get TimePlanningChannels.id } get TimePlanningChannels.id
} }
} }

View file

@ -20,9 +20,8 @@ package net.moonleay.lilJudd.data.database.repository
import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData
import net.moonleay.lilJudd.data.database.tables.TimePlanningMessages import net.moonleay.lilJudd.data.database.tables.TimePlanningMessages
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
object TimePlanningMessagesRepository { object TimePlanningMessagesRepository {
@ -40,9 +39,7 @@ object TimePlanningMessagesRepository {
fun getWeek(stamp: Long): List<TimePlanningMessagesData> { fun getWeek(stamp: Long): List<TimePlanningMessagesData> {
val dataList = mutableListOf<TimePlanningMessagesData>() val dataList = mutableListOf<TimePlanningMessagesData>()
transaction { transaction {
for (pnr in TimePlanningMessages.select { for (pnr in TimePlanningMessages.selectAll().where { TimePlanningMessages.weekstamp eq (stamp) }) {
TimePlanningMessages.weekstamp eq (stamp)
}) {
dataList.add( dataList.add(
TimePlanningMessagesData( TimePlanningMessagesData(
pnr[TimePlanningMessages.id], pnr[TimePlanningMessages.id],
@ -59,9 +56,8 @@ object TimePlanningMessagesRepository {
fun getWeekInChannel(stamp: Long, channelID: Long): TimePlanningMessagesData? = fun getWeekInChannel(stamp: Long, channelID: Long): TimePlanningMessagesData? =
transaction { transaction {
TimePlanningMessages.select { TimePlanningMessages.selectAll()
TimePlanningMessages.weekstamp eq (stamp) and (TimePlanningMessages.channelid eq channelID) .where { TimePlanningMessages.weekstamp eq (stamp) and (TimePlanningMessages.channelid eq channelID) }.firstOrNull()?.let {
}.firstOrNull()?.let {
TimePlanningMessagesData( TimePlanningMessagesData(
it[TimePlanningMessages.id], it[TimePlanningMessages.id],
it[TimePlanningMessages.serverid], it[TimePlanningMessages.serverid],

View file

@ -41,7 +41,7 @@ class SendPlannerExtension : Extension() {
get() = false get() = false
override suspend fun setup() { override suspend fun setup() {
publicSlashCommand() { publicSlashCommand {
name = "sendplanner" name = "sendplanner"
description = "Send the planner for the current week" description = "Send the planner for the current week"
this.action { this.action {

View file

@ -34,7 +34,7 @@ class UpdateRolesExtension : Extension() {
get() = false get() = false
override suspend fun setup() { override suspend fun setup() {
publicSlashCommand() { publicSlashCommand {
name = "updateroles" name = "updateroles"
description = "Update the roles of the members in the current server" description = "Update the roles of the members in the current server"
this.action { this.action {