fix: fixed sorting top lists not working
This commit is contained in:
parent
338d00c990
commit
e4102cc56b
1 changed files with 12 additions and 8 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue