diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt index 3dd02d7..55765ee 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt @@ -75,11 +75,11 @@ class AcceptEditButton() : IEditButton { if (!found || mpdd == null) { return } - val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) ?: return + val role = guild.getRoleOrNull(Snowflake(mpdd.roleid)) ?: return val member = interaction.user.asMember(guild.id) ?: return // do the checks and update 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}") member.removeRole(role.id) } @@ -94,7 +94,7 @@ class AcceptEditButton() : IEditButton { shouldEditButton = true } 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("Adding role to ${member.username}") member.addRole(role.id) } diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt index be99232..4f70ab7 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt @@ -72,9 +72,9 @@ class CancelEditButton : IEditButton { if (!found || mpdd == null) { return } - val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) ?: return + val role = guild.getRoleOrNull(Snowflake(mpdd.roleid)) ?: return val member = interaction.user.asMember(guild.id) - if (member.roleIds.contains(Snowflake(mpdd.roleID))) { + if (member.roleIds.contains(Snowflake(mpdd.roleid))) { member.removeRole(role.id) } Bot.bot.kordRef.getChannelOf(interaction.channelId)!!.getMessage(m.id).edit { diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt index 9a3de97..3d0e0bd 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt @@ -75,10 +75,10 @@ class DeclineEditButton : IEditButton { if (!found || mpdd == null) { return } - val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) ?: return + val role = guild.getRoleOrNull(Snowflake(mpdd.roleid)) ?: return val member = interaction.user.asMember(guild.id) ?: return 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}") member.removeRole(role.id) } @@ -88,7 +88,7 @@ class DeclineEditButton : IEditButton { shouldEditButton = true } if (!m.embeds[0].fields[1].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}") member.removeRole(role.id) } diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt index f48dc28..451278e 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt @@ -20,13 +20,13 @@ package net.moonleay.lilJudd.data.entry data class MatchPlanningDataData( val id: Int, - val serverID: Long, - val channelID: Long, - val matchType: String, - val registererID: Long, - val roleID: Long, - val opponentName: String, - val messageID: Long, + val serverid: Long, + val channelid: Long, + val matchtype: String, + val registererid: Long, + val roleid: Long, + val opponentname: String, + val messageid: Long, val timestamp: Long, - val jobString: String + val jobstr: String ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt index a36f351..fc15729 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt @@ -20,7 +20,7 @@ package net.moonleay.lilJudd.data.entry data class PlanningNotifierRolesData( val serverID: Long, // The id of the server - val channelID: Long, // The id of the channel - val hasTimeRoleID: Long, // The id of the role that has time today - val wantsToBeNotifiedID: Long // The id of the role that wants to be notified + val channelId: Long, // The id of the channel + val hastimeroleid: Long, // The id of the role that has time today + val wantstobenotifid: Long // The id of the role that wants to be notified ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt deleted file mode 100644 index 2eebba4..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.data.entry - -data class TimePlanningChannelsData( - val serverID: Long, - val channelID: Long, -) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt index 6c5b2fc..c4de368 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt @@ -19,8 +19,8 @@ package net.moonleay.lilJudd.data.entry data class TimePlanningMessagesData( - val serverID: Long, // The discord server id - val channelID: Long, // The discord channel id + val serverid: Long, // The discord server id + val channelid: Long, // The discord channel id val weekstamp: Long, // The timestamp of the monday of the week at 4am UTC - val messageIDs: String // IDs are in the following format: "{weekdayNr}:{id};{weekdayNr}:{id};[etc.]" + val messageids: String // IDs are in the following format: "{weekdayNr}:{id};{weekdayNr}:{id};[etc.]" ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt index 8683dd5..f883347 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt @@ -80,15 +80,15 @@ object AvailabilityManager : IFeature { for (snf in messageMap.keys) { // snf = Snowflake val data = messageMap[snf]!! // this is the data of the table - if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) + if (Bot.bot.kordRef.getChannel(Snowflake(data.channelid)) == null) continue // This channel does not exist anymore. if (roleMap.isEmpty()) { Logger.out("No saved roles. Canceling.") return } - val roleData = roleMap[data.channelID] // Get the role data + val roleData = roleMap[data.channelid] // Get the role data if (roleData == null) { - Logger.out("Role for channel ${data.channelID} does not exist") + Logger.out("Role for channel ${data.channelid} does not exist") continue // this took way to long to find out that this was the issue } this.updateInChannel(snf, data, roleData) @@ -130,10 +130,10 @@ object AvailabilityManager : IFeature { Logger.out("Could not find data for channel ${snf.value}") return } - if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) + if (Bot.bot.kordRef.getChannel(Snowflake(data.channelid)) == null) return // This channel does not exist anymore. if (roleData == null) { - Logger.out("Role for channel ${data.channelID} does not exist") + Logger.out("Role for channel ${data.channelid} does not exist") return // this took way to long to find out that this was the issue } updateInChannel(snf, data, roleData) @@ -141,18 +141,18 @@ object AvailabilityManager : IFeature { @OptIn(PrivilegedIntent::class) suspend fun updateInChannel(snf: Snowflake, tpmd: TimePlanningMessagesData, pnrd: PlanningNotifierRolesData) { - if (Bot.bot.kordRef.getChannel(Snowflake(tpmd.channelID)) == null) + if (Bot.bot.kordRef.getChannel(Snowflake(tpmd.channelid)) == null) return // This channel does not exist anymore. val c = - Bot.bot.kordRef.getChannelOf(Snowflake(tpmd.channelID))!! // Get the channel as MessageChannel - if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverID)) == null) { + Bot.bot.kordRef.getChannelOf(Snowflake(tpmd.channelid))!! // Get the channel as MessageChannel + if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverid)) == null) { Logger.out("Guild not found.") return } val weekday = ZonedDateTime.now().dayOfWeek // The current week day val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() * 1000 // The current week time stamp Logger.out("It is week ${weekStamp} and day ${weekday}/${TimeUtil.getDayOfMonthInt(weekday)} of the week.") - val g = Bot.bot.kordRef.getGuildOrThrow(Snowflake(tpmd.serverID)) + val g = Bot.bot.kordRef.getGuildOrThrow(Snowflake(tpmd.serverid)) // Get all members with the role val mce = g.requestMembers { this.requestAllMembers() @@ -161,8 +161,8 @@ object AvailabilityManager : IFeature { memberchunkevent.members.forEach { if (!it.isNullOrBot()) { // Check if the member is a bot Logger.out("Checking member ${it.id.value} (${it.username})") - if (it.roleIds.contains(Snowflake(pnrd.hasTimeRoleID))) { - it.removeRole(Snowflake(pnrd.hasTimeRoleID)) + if (it.roleIds.contains(Snowflake(pnrd.hastimeroleid))) { + it.removeRole(Snowflake(pnrd.hastimeroleid)) Logger.out("Removed role from ${it.username}") // Removed the role } } @@ -174,7 +174,7 @@ object AvailabilityManager : IFeature { // This stores the ids of the messages. // The format is weekdaNR:ID // The last entry (nr 8) is empty, so we can ignore it - val messageIdSplit = tpmd.messageIDs.split(";").subList(0, 7) + val messageIdSplit = tpmd.messageids.split(";").subList(0, 7) for (mid in messageIdSplit) { Logger.out("Checking id $mid") if (!mid.startsWith((TimeUtil.getDayOfMonthInt(weekday) - 1).toString(), true)) @@ -192,15 +192,15 @@ object AvailabilityManager : IFeature { val targets = EmbedUtil.getAllUsersInTheFirstXTables(2, message.embeds[0]) for (tid in targets) { Logger.out("Checking id $tid") - if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverID))!! + if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverid))!! .getMemberOrNull(Snowflake(tid)) == null ) continue// This member does not exist anymore. - val member = Bot.bot.kordRef.getGuildOrThrow(Snowflake(tpmd.serverID)) + val member = Bot.bot.kordRef.getGuildOrThrow(Snowflake(tpmd.serverid)) .getMember(Snowflake(tid)) // Get the member - if (member.roleIds.contains(Snowflake(pnrd.hasTimeRoleID))) + if (member.roleIds.contains(Snowflake(pnrd.hastimeroleid))) continue // This member already has the role - member.addRole(Snowflake(pnrd.hasTimeRoleID)) // Add the role + member.addRole(Snowflake(pnrd.hastimeroleid)) // Add the role Logger.out("Added role to ${member.username}") } Logger.out("Done with message. Moving on...") diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt index aeb2203..1591545 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt @@ -57,9 +57,9 @@ object MatchManager { Logger.out("Checking match role ${data.id}...") if (data.timestamp.toLong() < System.currentTimeMillis()) { Logger.out("Match role ${data.id} is expired, removing...") - this.removeRoleFromGuild(data.serverID, data.roleID) + this.removeRoleFromGuild(data.serverid, data.roleid) transaction { - MatchPlanningData.deleteWhere { MatchPlanningData.messageid eq data.messageID } + MatchPlanningData.deleteWhere { MatchPlanningData.messageid eq data.messageid } } continue } @@ -71,9 +71,9 @@ object MatchManager { private fun registerJob(data: MatchPlanningDataData) { JobManager.addJob( MatchJob( - data.jobString, + data.jobstr, data.id, - "fromdb-${data.matchType}_Vs_${data.opponentName}_[${data.id}]-${data.serverID}_${data.channelID}" + "fromdb-${data.matchtype}_Vs_${data.opponentname}_[${data.id}]-${data.serverid}_${data.channelid}" ) ) Logger.out("Registered job for match ${data.id}...") diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt index 8a66ee7..677520d 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt @@ -94,7 +94,7 @@ object TimeManager : IFeature { if (roleMap != null && roleMap.keys.contains(ch) && roleMap[ch] != null) { c.createMessage { this.content = - "The weekly planning starts now <@&${Snowflake(roleMap[ch]?.wantsToBeNotifiedID!!)}>" + "The weekly planning starts now <@&${Snowflake(roleMap[ch]?.wantstobenotifid!!)}>" this.embeds.add( MessageUtil.getEmbed( EmbedColor.INFO, diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt index f350b86..89b33e4 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt @@ -67,12 +67,12 @@ class MatchJob( ) } } - val guild = Bot.bot.kordRef.getGuildOrNull(Snowflake(mpdd.serverID)) + val guild = Bot.bot.kordRef.getGuildOrNull(Snowflake(mpdd.serverid)) if (guild == null) { Logger.out("Guild not found.") return } - val r = guild.getRoleOrNull(Snowflake(mpdd.roleID)) + val r = guild.getRoleOrNull(Snowflake(mpdd.roleid)) if (r == null) { Logger.out("Role not found.") return