From 3d1b2750e556dc95889b40a5826851b376a3952e Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 18:31:45 +0200 Subject: [PATCH] chore: fixed naming in data objects Signed-off-by: moonleay --- .../buttons/matchplanner/AcceptEditButton.kt | 6 ++-- .../buttons/matchplanner/CancelEditButton.kt | 4 +-- .../buttons/matchplanner/DeclineEditButton.kt | 6 ++-- .../data/entry/MatchPlanningDataData.kt | 16 +++++----- .../data/entry/PlanningNotifierRolesData.kt | 6 ++-- .../data/entry/TimePlanningMessagesData.kt | 6 ++-- .../lilJudd/features/AvailabilityManager.kt | 32 +++++++++---------- .../moonleay/lilJudd/features/MatchManager.kt | 8 ++--- .../moonleay/lilJudd/features/TimeManager.kt | 2 +- .../net/moonleay/lilJudd/jobs/MatchJob.kt | 4 +-- 10 files changed, 45 insertions(+), 45 deletions(-) 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 55765ee..3dd02d7 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 4f70ab7..be99232 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 3d0e0bd..9a3de97 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 451278e..f48dc28 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 jobstr: String + val jobString: 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 fc15729..a36f351 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 wantstobenotifid: 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 wantsToBeNotifiedID: Long // The id of the role that wants to be notified ) 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 c4de368..6c5b2fc 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 f883347..8683dd5 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 1591545..aeb2203 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.jobstr, + data.jobString, 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 677520d..8a66ee7 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]?.wantstobenotifid!!)}>" + "The weekly planning starts now <@&${Snowflake(roleMap[ch]?.wantsToBeNotifiedID!!)}>" 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 89b33e4..f350b86 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