chore: fixed naming in data objects
All checks were successful
Build Gradle project / build-gradle-project (push) Successful in 2m49s

Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
moonleay 2023-09-14 18:31:45 +02:00
parent 99c607efd4
commit b77271517d
10 changed files with 45 additions and 45 deletions

View file

@ -75,11 +75,11 @@ class AcceptEditButton() : IEditButton {
if (!found || mpdd == null) { if (!found || mpdd == null) {
return 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 val member = interaction.user.asMember(guild.id) ?: return
// 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))) {
Logger.out("Removing role from ${member.username}") Logger.out("Removing role from ${member.username}")
member.removeRole(role.id) member.removeRole(role.id)
} }
@ -94,7 +94,7 @@ class AcceptEditButton() : IEditButton {
shouldEditButton = true shouldEditButton = true
} }
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("Adding role to ${member.username}") Logger.out("Adding role to ${member.username}")
member.addRole(role.id) member.addRole(role.id)
} }

View file

@ -72,9 +72,9 @@ class CancelEditButton : IEditButton {
if (!found || mpdd == null) { if (!found || mpdd == null) {
return return
} }
val role = guild.getRoleOrNull(Snowflake(mpdd.roleid)) ?: return val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) ?: return
val member = interaction.user.asMember(guild.id) 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) member.removeRole(role.id)
} }
Bot.bot.kordRef.getChannelOf<MessageChannel>(interaction.channelId)!!.getMessage(m.id).edit { Bot.bot.kordRef.getChannelOf<MessageChannel>(interaction.channelId)!!.getMessage(m.id).edit {

View file

@ -75,10 +75,10 @@ class DeclineEditButton : IEditButton {
if (!found || mpdd == null) { if (!found || mpdd == null) {
return 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 val member = interaction.user.asMember(guild.id) ?: return
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}")
member.removeRole(role.id) member.removeRole(role.id)
} }
@ -88,7 +88,7 @@ class DeclineEditButton : IEditButton {
shouldEditButton = true shouldEditButton = true
} }
if (!m.embeds[0].fields[1].value.contains(user.id.value.toString())) { 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}") Logger.out("Removing role from ${member.username}")
member.removeRole(role.id) member.removeRole(role.id)
} }

View file

@ -20,13 +20,13 @@ package net.moonleay.lilJudd.data.entry
data class MatchPlanningDataData( data class MatchPlanningDataData(
val id: Int, val id: Int,
val serverid: Long, val serverID: Long,
val channelid: Long, val channelID: Long,
val matchtype: String, val matchType: String,
val registererid: Long, val registererID: Long,
val roleid: Long, val roleID: Long,
val opponentname: String, val opponentName: String,
val messageid: Long, val messageID: Long,
val timestamp: Long, val timestamp: Long,
val jobstr: String val jobString: String
) )

View file

@ -20,7 +20,7 @@ package net.moonleay.lilJudd.data.entry
data class PlanningNotifierRolesData( data class PlanningNotifierRolesData(
val serverID: Long, // The id of the server val serverID: Long, // The id of the server
val channelId: Long, // The id of the channel val channelID: Long, // The id of the channel
val hastimeroleid: Long, // The id of the role that has time today 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 wantsToBeNotifiedID: Long // The id of the role that wants to be notified
) )

View file

@ -19,8 +19,8 @@
package net.moonleay.lilJudd.data.entry package net.moonleay.lilJudd.data.entry
data class TimePlanningMessagesData( data class TimePlanningMessagesData(
val serverid: Long, // The discord server id val serverID: Long, // The discord server id
val channelid: Long, // The discord channel id val channelID: Long, // The discord channel id
val weekstamp: Long, // The timestamp of the monday of the week at 4am UTC 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.]"
) )

View file

@ -80,15 +80,15 @@ object AvailabilityManager : IFeature {
for (snf in messageMap.keys) { // snf = Snowflake for (snf in messageMap.keys) { // snf = Snowflake
val data = messageMap[snf]!! // this is the data of the table 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. continue // This channel does not exist anymore.
if (roleMap.isEmpty()) { if (roleMap.isEmpty()) {
Logger.out("No saved roles. Canceling.") Logger.out("No saved roles. Canceling.")
return return
} }
val roleData = roleMap[data.channelid] // Get the role data val roleData = roleMap[data.channelID] // Get the role data
if (roleData == null) { 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 continue // this took way to long to find out that this was the issue
} }
this.updateInChannel(snf, data, roleData) this.updateInChannel(snf, data, roleData)
@ -130,10 +130,10 @@ object AvailabilityManager : IFeature {
Logger.out("Could not find data for channel ${snf.value}") Logger.out("Could not find data for channel ${snf.value}")
return 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. return // This channel does not exist anymore.
if (roleData == null) { 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 return // this took way to long to find out that this was the issue
} }
updateInChannel(snf, data, roleData) updateInChannel(snf, data, roleData)
@ -141,18 +141,18 @@ object AvailabilityManager : IFeature {
@OptIn(PrivilegedIntent::class) @OptIn(PrivilegedIntent::class)
suspend fun updateInChannel(snf: Snowflake, tpmd: TimePlanningMessagesData, pnrd: PlanningNotifierRolesData) { 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. return // This channel does not exist anymore.
val c = val c =
Bot.bot.kordRef.getChannelOf<MessageChannel>(Snowflake(tpmd.channelid))!! // Get the channel as MessageChannel Bot.bot.kordRef.getChannelOf<MessageChannel>(Snowflake(tpmd.channelID))!! // Get the channel as MessageChannel
if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverid)) == null) { if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverID)) == null) {
Logger.out("Guild not found.") Logger.out("Guild not found.")
return return
} }
val weekday = ZonedDateTime.now().dayOfWeek // The current week day val weekday = ZonedDateTime.now().dayOfWeek // The current week day
val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() * 1000 // The current week time stamp 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.") 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 // Get all members with the role
val mce = g.requestMembers { val mce = g.requestMembers {
this.requestAllMembers() this.requestAllMembers()
@ -161,8 +161,8 @@ object AvailabilityManager : IFeature {
memberchunkevent.members.forEach { memberchunkevent.members.forEach {
if (!it.isNullOrBot()) { // Check if the member is a bot if (!it.isNullOrBot()) { // Check if the member is a bot
Logger.out("Checking member ${it.id.value} (${it.username})") Logger.out("Checking member ${it.id.value} (${it.username})")
if (it.roleIds.contains(Snowflake(pnrd.hastimeroleid))) { if (it.roleIds.contains(Snowflake(pnrd.hasTimeRoleID))) {
it.removeRole(Snowflake(pnrd.hastimeroleid)) it.removeRole(Snowflake(pnrd.hasTimeRoleID))
Logger.out("Removed role from ${it.username}") // Removed the role Logger.out("Removed role from ${it.username}") // Removed the role
} }
} }
@ -174,7 +174,7 @@ object AvailabilityManager : IFeature {
// This stores the ids of the messages. // This stores the ids of the messages.
// The format is weekdaNR:ID // The format is weekdaNR:ID
// The last entry (nr 8) is empty, so we can ignore it // 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) { for (mid in messageIdSplit) {
Logger.out("Checking id $mid") Logger.out("Checking id $mid")
if (!mid.startsWith((TimeUtil.getDayOfMonthInt(weekday) - 1).toString(), true)) if (!mid.startsWith((TimeUtil.getDayOfMonthInt(weekday) - 1).toString(), true))
@ -192,15 +192,15 @@ object AvailabilityManager : IFeature {
val targets = EmbedUtil.getAllUsersInTheFirstXTables(2, message.embeds[0]) val targets = EmbedUtil.getAllUsersInTheFirstXTables(2, message.embeds[0])
for (tid in targets) { for (tid in targets) {
Logger.out("Checking id $tid") 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 .getMemberOrNull(Snowflake(tid)) == null
) )
continue// This member does not exist anymore. 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 .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 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("Added role to ${member.username}")
} }
Logger.out("Done with message. Moving on...") Logger.out("Done with message. Moving on...")

View file

@ -57,9 +57,9 @@ object MatchManager {
Logger.out("Checking match role ${data.id}...") Logger.out("Checking match role ${data.id}...")
if (data.timestamp.toLong() < System.currentTimeMillis()) { if (data.timestamp.toLong() < System.currentTimeMillis()) {
Logger.out("Match role ${data.id} is expired, removing...") Logger.out("Match role ${data.id} is expired, removing...")
this.removeRoleFromGuild(data.serverid, data.roleid) this.removeRoleFromGuild(data.serverID, data.roleID)
transaction { transaction {
MatchPlanningData.deleteWhere { MatchPlanningData.messageid eq data.messageid } MatchPlanningData.deleteWhere { MatchPlanningData.messageid eq data.messageID }
} }
continue continue
} }
@ -71,9 +71,9 @@ object MatchManager {
private fun registerJob(data: MatchPlanningDataData) { private fun registerJob(data: MatchPlanningDataData) {
JobManager.addJob( JobManager.addJob(
MatchJob( MatchJob(
data.jobstr, data.jobString,
data.id, 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}...") Logger.out("Registered job for match ${data.id}...")

View file

@ -94,7 +94,7 @@ object TimeManager : IFeature {
if (roleMap != null && roleMap.keys.contains(ch) && roleMap[ch] != null) { if (roleMap != null && roleMap.keys.contains(ch) && roleMap[ch] != null) {
c.createMessage { c.createMessage {
this.content = this.content =
"The weekly planning starts now <@&${Snowflake(roleMap[ch]?.wantstobenotifid!!)}>" "The weekly planning starts now <@&${Snowflake(roleMap[ch]?.wantsToBeNotifiedID!!)}>"
this.embeds.add( this.embeds.add(
MessageUtil.getEmbed( MessageUtil.getEmbed(
EmbedColor.INFO, EmbedColor.INFO,

View file

@ -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) { if (guild == null) {
Logger.out("Guild not found.") Logger.out("Guild not found.")
return return
} }
val r = guild.getRoleOrNull(Snowflake(mpdd.roleid)) val r = guild.getRoleOrNull(Snowflake(mpdd.roleID))
if (r == null) { if (r == null) {
Logger.out("Role not found.") Logger.out("Role not found.")
return return