fix: fixed issues with timestamps
Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
parent
4a0792af08
commit
cd37bd1242
3 changed files with 16 additions and 11 deletions
|
@ -108,7 +108,7 @@ class MatchExtension : Extension() {
|
|||
role.id.value.toLong(),
|
||||
opponent,
|
||||
msg.id.value.toLong(),
|
||||
(zdt.toEpochSecond() * 1000),
|
||||
(zdt.toEpochSecond()),
|
||||
jobString
|
||||
)
|
||||
)
|
||||
|
|
|
@ -105,7 +105,7 @@ class SendPlannerExtension : Extension() {
|
|||
-1,
|
||||
c.data.guildId.value?.value!!.toLong(),
|
||||
c.id.value.toLong(),
|
||||
(TimeUtil.getWeekStamp().toEpochSecond() * 1000),
|
||||
(TimeUtil.getWeekStamp().toEpochSecond()),
|
||||
msgStr
|
||||
)
|
||||
)
|
||||
|
|
|
@ -47,18 +47,21 @@ object AvailabilityManager : IFeature {
|
|||
Logger.out("Starting to update roles...")
|
||||
|
||||
// ChannelID, Data
|
||||
val messages = TimePlanningMessagesRepository.getWeek(TimeUtil.getWeekStamp().toEpochSecond() * 1000)
|
||||
val messages = TimePlanningMessagesRepository.getWeek(TimeUtil.getWeekStamp().toEpochSecond())
|
||||
.associateBy { it.channelID }
|
||||
val targetedRoles = PlanningNotifierRolesRepository.getAll().associateBy { it.channelID }
|
||||
if (targetedRoles.isEmpty()) {
|
||||
Logger.out("No saved roles. Canceling.")
|
||||
return
|
||||
}
|
||||
|
||||
for (id in messages.keys) {
|
||||
val snf = Snowflake(id) // snf = Snowflake
|
||||
val data = messages[id]!! // this is the data of the table
|
||||
if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null)
|
||||
continue // This channel does not exist anymore.
|
||||
if (targetedRoles.isEmpty()) {
|
||||
Logger.out("No saved roles. Canceling.")
|
||||
return
|
||||
if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) {
|
||||
// This channel does not exist anymore.
|
||||
Logger.out("Warning: Channel ${data.channelID} does not exist anymore. Skipping.")
|
||||
continue
|
||||
}
|
||||
val roleData = targetedRoles[data.channelID] // Get the role data
|
||||
if (roleData == null) {
|
||||
|
@ -71,15 +74,17 @@ object AvailabilityManager : IFeature {
|
|||
}
|
||||
|
||||
suspend fun updateInChannel(snf: Snowflake) {
|
||||
val stamp = TimeUtil.getWeekStamp().toEpochSecond()
|
||||
Logger.out("Weekstamp: $stamp")
|
||||
val messageData = TimePlanningMessagesRepository.getWeekInChannel(
|
||||
TimeUtil.getWeekStamp().toEpochSecond() * 1000,
|
||||
stamp,
|
||||
snf.value.toLong()
|
||||
)
|
||||
val roleData = PlanningNotifierRolesRepository.getForChannel(snf.value.toLong())
|
||||
if (messageData == null) {
|
||||
Logger.out("Could not find data for channel ${snf.value}")
|
||||
return
|
||||
}
|
||||
val roleData = PlanningNotifierRolesRepository.getForChannel(snf.value.toLong())
|
||||
if (roleData == null) {
|
||||
Logger.out("Role for channel ${messageData.channelID} does not exist")
|
||||
return // this took way to long to find out that this was the issue
|
||||
|
@ -93,7 +98,7 @@ object AvailabilityManager : IFeature {
|
|||
return // This channel does not exist anymore.
|
||||
val c = Bot.bot.kordRef.getChannelOf<MessageChannel>(snf)!! // Get the channel as MessageChannel
|
||||
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() // 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.getGuild(Snowflake(tpmd.serverID))
|
||||
// Get all members with the role
|
||||
|
|
Loading…
Reference in a new issue