chore: fixed naming in data objects

Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
moonleay 2023-09-14 18:31:45 +02:00
parent 3695f716ed
commit 3d1b2750e5
Signed by: moonleay
GPG key ID: 82667543CCD715FB
10 changed files with 45 additions and 45 deletions

View file

@ -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)
}

View file

@ -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<MessageChannel>(interaction.channelId)!!.getMessage(m.id).edit {

View file

@ -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)
}

View file

@ -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
)

View file

@ -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
)

View file

@ -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.]"
)

View file

@ -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<MessageChannel>(Snowflake(tpmd.channelid))!! // Get the channel as MessageChannel
if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverid)) == null) {
Bot.bot.kordRef.getChannelOf<MessageChannel>(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...")

View file

@ -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}...")

View file

@ -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,

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) {
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