Compare commits
4 commits
13d07b1866
...
e4102cc56b
Author | SHA1 | Date | |
---|---|---|---|
e4102cc56b | |||
338d00c990 | |||
aab31d8d41 | |||
8defc45b12 |
4 changed files with 35 additions and 14 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.5"
|
||||
?: "0.0.6"
|
||||
|
||||
val kordver = "1.5.9-SNAPSHOT"
|
||||
val coroutinesver = "1.7.3"
|
||||
|
|
|
@ -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,6 +42,22 @@ 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(
|
||||
|
@ -94,7 +110,7 @@ class AwakeExtension : Extension() {
|
|||
"Good morning, ${u.username}!",
|
||||
ud.customWakeupMessage.replace("#user", u.mention) + "\n" +
|
||||
"\n" +
|
||||
"${if (streakCoins > 0) "[${ud.currentStreak} day streak]" else ""}\n" +
|
||||
"${if (ud.currentStreak > 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,
|
||||
|
|
|
@ -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,22 +49,27 @@ class TopExtension : Extension() {
|
|||
val g = this.guild!!.asGuild()
|
||||
val targetList = this.arguments.listType
|
||||
val all = UserRepository.getAllUsers()
|
||||
val allInGuild = all.filter { g.getMemberOrNull(Snowflake(it.userid)) != null }
|
||||
var allInGuild = all.filter { g.getMemberOrNull(Snowflake(it.userid)) != null }
|
||||
when(targetList) {
|
||||
ListTypes.TOPSTREAK -> {
|
||||
allInGuild.sortedByDescending { it.longestStreak }
|
||||
Logger.out("Sorting by topstreak")
|
||||
allInGuild = allInGuild.sortedByDescending { it.longestStreak }
|
||||
}
|
||||
ListTypes.STREAK -> {
|
||||
allInGuild.sortedByDescending { it.currentStreak }
|
||||
Logger.out("Sorting by streak")
|
||||
allInGuild = allInGuild.sortedByDescending { it.currentStreak }
|
||||
}
|
||||
ListTypes.TOPCOINS -> {
|
||||
allInGuild.sortedByDescending { it.coinsCollected }
|
||||
Logger.out("Sorting by topcoins")
|
||||
allInGuild = allInGuild.sortedByDescending { it.coinsCollected }
|
||||
}
|
||||
ListTypes.COINS -> {
|
||||
allInGuild.sortedByDescending { it.coins }
|
||||
Logger.out("Sorting by coins")
|
||||
allInGuild = allInGuild.sortedByDescending { it.coins }
|
||||
}
|
||||
ListTypes.FAILS -> {
|
||||
allInGuild.sortedByDescending { it.numberOfFails }
|
||||
Logger.out("Sorting by fails")
|
||||
allInGuild = allInGuild.sortedByDescending { it.numberOfFails }
|
||||
}
|
||||
}
|
||||
var msg = ""
|
||||
|
@ -87,7 +92,6 @@ 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()
|
||||
|
|
|
@ -47,6 +47,7 @@ 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
|
||||
|
@ -61,11 +62,11 @@ class WakeupJob(override val jobName: String, override val jobIncoming: String,
|
|||
MessageUtil.getEmbed(
|
||||
EmbedColor.ERROR,
|
||||
"You failed to wake up!",
|
||||
"You failed to wake up at ${TimeUtil.getHourAndMinuteFromStamp(user.nextWakeup)}!\n" +
|
||||
"You lost a streak of ${user.currentStreak}" +
|
||||
"${userasuser.mention} failed to wake up at ${TimeUtil.getHourAndMinuteFromStamp(user.nextWakeup)}!\n" +
|
||||
"You lost a streak of $brokenStreak" +
|
||||
if(isBiggestStreakYet) ", which was your biggest streak yet." else "." +
|
||||
"\nYou can try again tomorrow with `/time`",
|
||||
user.userid.toString(),
|
||||
"Automated Message",
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue