Compare commits

...

7 commits

Author SHA1 Message Date
883940c8fd Merge remote-tracking branch 'origin/master'
All checks were successful
Build Gradle project / build-gradle-project (push) Successful in 4m13s
2023-09-06 22:10:39 +02:00
18cd26c456 chore: bump version
Signed-off-by: moonleay <contact@moonleay.net>
2023-09-06 22:10:17 +02:00
a3c1344f1a feat: Roles now update on button press
Signed-off-by: moonleay <contact@moonleay.net>
2023-09-06 22:09:59 +02:00
f552ea4faa chore: improved readability
Signed-off-by: moonleay <contact@moonleay.net>
2023-09-06 22:06:14 +02:00
d10f8901c9 fix: fixed AvailabilityManager
Signed-off-by: moonleay <contact@moonleay.net>
2023-09-06 22:05:29 +02:00
925398db65 fix: fixed weekstamp
Signed-off-by: moonleay <contact@moonleay.net>
2023-09-06 22:03:50 +02:00
b258747086 chore: improved imports
Signed-off-by: moonleay <contact@moonleay.net>
2023-09-06 21:59:41 +02:00
8 changed files with 21 additions and 15 deletions

View file

@ -32,7 +32,7 @@ val ownerID = 372703841151614976L
group = "net.moonleay.liljudd" group = "net.moonleay.liljudd"
version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" }
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
?: "2.4.2" ?: "2.4.3"
val kordver = "1.5.6" val kordver = "1.5.6"
val coroutinesver = "1.1.0" val coroutinesver = "1.1.0"

View file

@ -35,10 +35,7 @@ import net.moonleay.botendo.build.BuildConstants
import net.moonleay.lilJudd.buttons.component.EditButtonManager import net.moonleay.lilJudd.buttons.component.EditButtonManager
import net.moonleay.lilJudd.data.CredentialManager import net.moonleay.lilJudd.data.CredentialManager
import net.moonleay.lilJudd.data.DB import net.moonleay.lilJudd.data.DB
import net.moonleay.lilJudd.extensions.FeatureManageExtension import net.moonleay.lilJudd.extensions.*
import net.moonleay.lilJudd.extensions.MatchExtension
import net.moonleay.lilJudd.extensions.SendPlannerExtension
import net.moonleay.lilJudd.extensions.VersionExtension
import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.features.AvailabilityManager
import net.moonleay.lilJudd.features.MatchManager import net.moonleay.lilJudd.features.MatchManager
import net.moonleay.lilJudd.features.TimeManager import net.moonleay.lilJudd.features.TimeManager
@ -103,7 +100,7 @@ object Bot {
add(::FeatureManageExtension) add(::FeatureManageExtension)
add(::SendPlannerExtension) add(::SendPlannerExtension)
add(::MatchExtension) add(::MatchExtension)
//add(::UpdateRolesExtension) // This command is only for debugging purposes add(::UpdateRolesExtension) // This command is only for debugging purposes
//add(::TestExtension) // See comment in TestExtension.kt //add(::TestExtension) // See comment in TestExtension.kt
} }

View file

@ -27,6 +27,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction
import dev.kord.rest.builder.message.modify.embed import dev.kord.rest.builder.message.modify.embed
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.buttons.component.IEditButton import net.moonleay.lilJudd.buttons.component.IEditButton
import net.moonleay.lilJudd.features.AvailabilityManager
import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.EmbedUtil
class IsAvailableEditButton : IEditButton { class IsAvailableEditButton : IEditButton {
@ -62,5 +63,6 @@ class IsAvailableEditButton : IEditButton {
} }
} }
} }
AvailabilityManager.runThread()
} }
} }

View file

@ -27,6 +27,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction
import dev.kord.rest.builder.message.modify.embed import dev.kord.rest.builder.message.modify.embed
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.buttons.component.IEditButton import net.moonleay.lilJudd.buttons.component.IEditButton
import net.moonleay.lilJudd.features.AvailabilityManager
import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.EmbedUtil
class MaybeAvailableEditButton : IEditButton { class MaybeAvailableEditButton : IEditButton {
@ -62,5 +63,6 @@ class MaybeAvailableEditButton : IEditButton {
} }
} }
} }
AvailabilityManager.runThread()
} }
} }

View file

@ -27,6 +27,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction
import dev.kord.rest.builder.message.modify.embed import dev.kord.rest.builder.message.modify.embed
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.buttons.component.IEditButton import net.moonleay.lilJudd.buttons.component.IEditButton
import net.moonleay.lilJudd.features.AvailabilityManager
import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.EmbedUtil
class NotAvailableEditButton : IEditButton { class NotAvailableEditButton : IEditButton {
@ -62,5 +63,6 @@ class NotAvailableEditButton : IEditButton {
} }
} }
} }
AvailabilityManager.runThread()
} }
} }

View file

@ -107,10 +107,10 @@ class SendPlannerExtension : Extension() {
// Save the message ids // Save the message ids
transaction { transaction {
TimePlanningMessages.insert { TimePlanningMessages.insert {
it[serverid] = c.data.guildId.value.toString() it[TimePlanningMessages.serverid] = c.data.guildId.value.toString()
it[channelid] = c.id.value.toString() it[TimePlanningMessages.channelid] = c.id.value.toString()
it[weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000).toString() it[TimePlanningMessages.weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000).toString()
it[messageids] = msgStr it[TimePlanningMessages.messageids] = msgStr
} get TimePlanningMessages.id } get TimePlanningMessages.id
} }
Logger.out("Finished with ${c.data.guildId.value}") Logger.out("Finished with ${c.data.guildId.value}")

View file

@ -96,8 +96,8 @@ object AvailabilityManager : IFeature {
} }
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 this channel does not exist") Logger.out("Role for channel ${data.channelid} does not exist")
return continue // this took way to long to find out that this was the issue
} }
val g = Bot.bot.kordRef.getGuildOrThrow(Snowflake(data.serverid)) val g = Bot.bot.kordRef.getGuildOrThrow(Snowflake(data.serverid))
// Get all members with the role // Get all members with the role
@ -106,9 +106,11 @@ object AvailabilityManager : IFeature {
} }
mce.collect { memberchunkevent -> mce.collect { memberchunkevent ->
memberchunkevent.members.forEach { memberchunkevent.members.forEach {
Logger.out("Checking member ${it.id.value}") Logger.out("Checking member ${it.id.value} (${it.username})")
if (it.roleIds.contains(Snowflake(roleData.hastimeroleid))) if (it.roleIds.contains(Snowflake(roleData.hastimeroleid))) {
it.removeRole(Snowflake(roleData.hastimeroleid)) it.removeRole(Snowflake(roleData.hastimeroleid))
Logger.out("Removed role from ${it.username}") // Removed the role
}
} }
} }

View file

@ -94,6 +94,7 @@ object TimeManager : IFeature {
if (Bot.bot.kordRef.getChannel(ch) == null) if (Bot.bot.kordRef.getChannel(ch) == null)
continue // TODO: Check if the channel is valid in another shard continue // TODO: Check if the channel is valid in another shard
val c = Bot.bot.kordRef.getChannelOf<MessageChannel>(ch)!! val c = Bot.bot.kordRef.getChannelOf<MessageChannel>(ch)!!
msgStr = ""
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 =
@ -152,7 +153,7 @@ object TimeManager : IFeature {
TimePlanningMessages.insert { TimePlanningMessages.insert {
it[TimePlanningMessages.serverid] = c.data.guildId.value.toString() it[TimePlanningMessages.serverid] = c.data.guildId.value.toString()
it[TimePlanningMessages.channelid] = c.id.value.toString() it[TimePlanningMessages.channelid] = c.id.value.toString()
it[TimePlanningMessages.weekstamp] = TimeUtil.getWeekStamp().toOffsetDateTime().toString() it[TimePlanningMessages.weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000).toString()
it[TimePlanningMessages.messageids] = msgStr it[TimePlanningMessages.messageids] = msgStr
} get TimePlanningMessages.id } get TimePlanningMessages.id
} }