fix: fixed time conversion errors, fixed list iteration errors
This commit is contained in:
parent
d57a05cc84
commit
13d07b1866
5 changed files with 19 additions and 9 deletions
|
@ -32,7 +32,7 @@ val ownerID = 372703841151614976L
|
|||
group = "net.moonleay.bedge"
|
||||
version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" }
|
||||
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
|
||||
?: "0.0.4"
|
||||
?: "0.0.5"
|
||||
|
||||
val kordver = "1.5.9-SNAPSHOT"
|
||||
val coroutinesver = "1.7.3"
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
|
|||
import com.kotlindiscord.kord.extensions.types.respond
|
||||
import dev.kord.common.entity.MessageFlags
|
||||
import net.moonleay.bedge.data.database.repository.UserRepository
|
||||
import net.moonleay.bedge.jobs.component.JobManager
|
||||
import net.moonleay.bedge.util.EmbedColor
|
||||
import net.moonleay.bedge.util.Logger
|
||||
import net.moonleay.bedge.util.MessageUtil
|
||||
|
@ -82,6 +83,9 @@ class AwakeExtension : Extension() {
|
|||
// update user
|
||||
UserRepository.update(ud)
|
||||
|
||||
// kill job
|
||||
JobManager.killNamedJob("WakeupJob${u.id.value.toLong()}")
|
||||
|
||||
// respond to user
|
||||
this.respond {
|
||||
this.embeds.add(
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.moonleay.bedge.data.database.entry.UserData
|
|||
import net.moonleay.bedge.data.database.repository.UserRepository
|
||||
import net.moonleay.bedge.util.EmbedColor
|
||||
import net.moonleay.bedge.util.MessageUtil
|
||||
import net.moonleay.bedge.util.TimeUtil
|
||||
|
||||
class ProfileExtension : Extension() {
|
||||
|
||||
|
@ -45,7 +46,7 @@ class ProfileExtension : Extension() {
|
|||
val user = this.user.asUser()
|
||||
if (this.arguments.target == null || this.arguments.target!!.id == this.user.id) {
|
||||
// User wants to see own profile
|
||||
val target = this.arguments.target!!
|
||||
val target = this.user.asUser()
|
||||
if(!UserRepository.doesUserExist(target.id.value)){
|
||||
this.respond {
|
||||
this.embeds.add(
|
||||
|
@ -95,8 +96,8 @@ class ProfileExtension : Extension() {
|
|||
|
||||
private fun getProfileMsg(target: UserData, targetUser: User, requester: User): EmbedBuilder = MessageUtil.getEmbedWithImage(
|
||||
EmbedColor.INFO,
|
||||
"Profile of ${target.userid}",
|
||||
"Account created: ${target.accountCreationDate}\n" +
|
||||
"Profile of ${targetUser.username}",
|
||||
"Account created: ${TimeUtil.convertFromUnixStamp(target.accountCreationDate)}\n" +
|
||||
"Current streak: ${target.currentStreak} days\n" +
|
||||
"Longest streak: ${target.longestStreak} days\n" +
|
||||
"Number of fails: ${target.numberOfFails}x\n" +
|
||||
|
|
|
@ -68,7 +68,7 @@ class TopExtension : Extension() {
|
|||
}
|
||||
}
|
||||
var msg = ""
|
||||
for (i in 0..9) {
|
||||
for (i in 0..if (allInGuild.size > 10) 9 else allInGuild.size-1) {
|
||||
val user = allInGuild[i]
|
||||
val row = getRow(user, g, targetList)
|
||||
msg += "${i+1}. ${row[0]}: ${row[1]}\n"
|
||||
|
@ -77,7 +77,7 @@ class TopExtension : Extension() {
|
|||
this.embeds.add(
|
||||
MessageUtil.getEmbed(
|
||||
EmbedColor.INFO,
|
||||
"Top ${targetList.name}",
|
||||
targetList.readableName,
|
||||
msg,
|
||||
u.username,
|
||||
)
|
||||
|
|
|
@ -149,6 +149,10 @@ object TimeUtil {
|
|||
return ZonedDateTime.of(localDateTime, zoneId)
|
||||
}
|
||||
|
||||
fun convertFromUnixStamp(stamp: Long): ZonedDateTime {
|
||||
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(stamp), ZoneId.of("UTC"))
|
||||
}
|
||||
|
||||
fun getCronjobStringFromDate(zdt: ZonedDateTime): String {
|
||||
// I'll have to add the possibility to set your timezone in the future
|
||||
// Only subtracting 1 hour, because I want to run the job 1 hour later
|
||||
|
@ -164,12 +168,13 @@ object TimeUtil {
|
|||
return ZonedDateTime.of(localDateTime, zoneId).toEpochSecond() * 1000
|
||||
}
|
||||
|
||||
|
||||
fun getZdtFromTime(inp: String, zone: String): ZonedDateTime {
|
||||
val formatter = DateTimeFormatter.ofPattern("HH:mm")
|
||||
val localDateTime = LocalDateTime.parse(inp, formatter)
|
||||
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")
|
||||
val zoneId = ZoneId.of(zone)
|
||||
val now = ZonedDateTime.now(zoneId)
|
||||
val zdtPre = ZonedDateTime.of(localDateTime, zoneId).withDayOfMonth(now.dayOfMonth).withMonth(now.monthValue).withYear(now.year)
|
||||
val localDateTime = LocalDateTime.parse("${now.year}-${now.monthValue}-${if (now.dayOfMonth < 10) "0${now.dayOfMonth}" else now.dayOfMonth} $inp", formatter)
|
||||
val zdtPre = ZonedDateTime.of(localDateTime, zoneId)
|
||||
if(zdtPre.isBefore(now))
|
||||
return zdtPre.plusDays(1)
|
||||
return zdtPre
|
||||
|
|
Loading…
Reference in a new issue