Compare commits

..

No commits in common. "e4102cc56ba10bccd1b9dfa4d563207a5c793a0b" and "13d07b186613a7434beea3fc4d1fb9cee0ea3191" have entirely different histories.

4 changed files with 14 additions and 35 deletions

View file

@ -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.6"
?: "0.0.5"
val kordver = "1.5.9-SNAPSHOT"
val coroutinesver = "1.7.3"

View file

@ -21,12 +21,12 @@ package net.moonleay.bedge.extensions
import com.kotlindiscord.kord.extensions.extensions.Extension
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
import net.moonleay.bedge.util.TimeUtil
class AwakeExtension : Extension() {
@ -42,22 +42,6 @@ class AwakeExtension : Extension() {
val ud = UserRepository.getUserByID(u.id.value)
if (ud.isAwake) {
// User is already awake
if (ud.currentStreak == 0) {
// User failed last time
this.respond {
this.embeds.add(
MessageUtil.getEmbed(
EmbedColor.ERROR,
"You failed last time!!",
"You failed to wake up at ${TimeUtil.getHourAndMinuteFromStamp(ud.nextWakeup)}!\n" +
"You can try again tomorrow with `/time`.",
u.username
)
)
}
return@action
}
this.respond {
this.embeds.add(
MessageUtil.getEmbed(
@ -110,7 +94,7 @@ class AwakeExtension : Extension() {
"Good morning, ${u.username}!",
ud.customWakeupMessage.replace("#user", u.mention) + "\n" +
"\n" +
"${if (ud.currentStreak > 0) "[${ud.currentStreak} day streak]" else ""}\n" +
"${if (streakCoins > 0) "[${ud.currentStreak} day streak]" else ""}\n" +
"${ud.coins} coin${if (ud.coins >= 1) "s" else ""} (+${streakCoins+1})\n" +
"lvl ${ud.level} (${ud.xp}/${neededXpForNextLvl} xp) [+${10 + bonusXp} xp]\n",
u.username,

View file

@ -25,11 +25,11 @@ import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.common.entity.Snowflake
import dev.kord.core.entity.Guild
import kotlinx.coroutines.flow.map
import net.moonleay.bedge.data.database.entry.UserData
import net.moonleay.bedge.data.database.repository.UserRepository
import net.moonleay.bedge.extensions.component.ListTypes
import net.moonleay.bedge.util.EmbedColor
import net.moonleay.bedge.util.Logger
import net.moonleay.bedge.util.MessageUtil
class TopExtension : Extension() {
@ -49,27 +49,22 @@ class TopExtension : Extension() {
val g = this.guild!!.asGuild()
val targetList = this.arguments.listType
val all = UserRepository.getAllUsers()
var allInGuild = all.filter { g.getMemberOrNull(Snowflake(it.userid)) != null }
val allInGuild = all.filter { g.getMemberOrNull(Snowflake(it.userid)) != null }
when(targetList) {
ListTypes.TOPSTREAK -> {
Logger.out("Sorting by topstreak")
allInGuild = allInGuild.sortedByDescending { it.longestStreak }
allInGuild.sortedByDescending { it.longestStreak }
}
ListTypes.STREAK -> {
Logger.out("Sorting by streak")
allInGuild = allInGuild.sortedByDescending { it.currentStreak }
allInGuild.sortedByDescending { it.currentStreak }
}
ListTypes.TOPCOINS -> {
Logger.out("Sorting by topcoins")
allInGuild = allInGuild.sortedByDescending { it.coinsCollected }
allInGuild.sortedByDescending { it.coinsCollected }
}
ListTypes.COINS -> {
Logger.out("Sorting by coins")
allInGuild = allInGuild.sortedByDescending { it.coins }
allInGuild.sortedByDescending { it.coins }
}
ListTypes.FAILS -> {
Logger.out("Sorting by fails")
allInGuild = allInGuild.sortedByDescending { it.numberOfFails }
allInGuild.sortedByDescending { it.numberOfFails }
}
}
var msg = ""
@ -92,6 +87,7 @@ class TopExtension : Extension() {
}
}
private suspend fun getRow(user: UserData, g: Guild, type: ListTypes): Array<String> {
val typeResult: String = when(type) {
ListTypes.TOPSTREAK -> user.longestStreak.toString()

View file

@ -47,7 +47,6 @@ class WakeupJob(override val jobName: String, override val jobIncoming: String,
val user = UserRepository.getUserByID(userId)
if (!user.isAwake){
// Failed
val userasuser = Bot.bot.kordRef.getUser(Snowflake(userId))!!.asUser()
val brokenStreak = user.currentStreak
val isBiggestStreakYet = user.currentStreak > user.longestStreak
++user.numberOfFails
@ -62,11 +61,11 @@ class WakeupJob(override val jobName: String, override val jobIncoming: String,
MessageUtil.getEmbed(
EmbedColor.ERROR,
"You failed to wake up!",
"${userasuser.mention} failed to wake up at ${TimeUtil.getHourAndMinuteFromStamp(user.nextWakeup)}!\n" +
"You lost a streak of $brokenStreak" +
"You failed to wake up at ${TimeUtil.getHourAndMinuteFromStamp(user.nextWakeup)}!\n" +
"You lost a streak of ${user.currentStreak}" +
if(isBiggestStreakYet) ", which was your biggest streak yet." else "." +
"\nYou can try again tomorrow with `/time`",
"Automated Message",
user.userid.toString(),
)
)
}