Compare commits
No commits in common. "e4102cc56ba10bccd1b9dfa4d563207a5c793a0b" and "13d07b186613a7434beea3fc4d1fb9cee0ea3191" have entirely different histories.
e4102cc56b
...
13d07b1866
4 changed files with 14 additions and 35 deletions
|
@ -32,7 +32,7 @@ val ownerID = 372703841151614976L
|
||||||
group = "net.moonleay.bedge"
|
group = "net.moonleay.bedge"
|
||||||
version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" }
|
version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" }
|
||||||
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
|
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
|
||||||
?: "0.0.6"
|
?: "0.0.5"
|
||||||
|
|
||||||
val kordver = "1.5.9-SNAPSHOT"
|
val kordver = "1.5.9-SNAPSHOT"
|
||||||
val coroutinesver = "1.7.3"
|
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.Extension
|
||||||
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
|
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
|
||||||
import com.kotlindiscord.kord.extensions.types.respond
|
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.data.database.repository.UserRepository
|
||||||
import net.moonleay.bedge.jobs.component.JobManager
|
import net.moonleay.bedge.jobs.component.JobManager
|
||||||
import net.moonleay.bedge.util.EmbedColor
|
import net.moonleay.bedge.util.EmbedColor
|
||||||
import net.moonleay.bedge.util.Logger
|
import net.moonleay.bedge.util.Logger
|
||||||
import net.moonleay.bedge.util.MessageUtil
|
import net.moonleay.bedge.util.MessageUtil
|
||||||
import net.moonleay.bedge.util.TimeUtil
|
|
||||||
|
|
||||||
|
|
||||||
class AwakeExtension : Extension() {
|
class AwakeExtension : Extension() {
|
||||||
|
@ -42,22 +42,6 @@ class AwakeExtension : Extension() {
|
||||||
val ud = UserRepository.getUserByID(u.id.value)
|
val ud = UserRepository.getUserByID(u.id.value)
|
||||||
if (ud.isAwake) {
|
if (ud.isAwake) {
|
||||||
// User is already awake
|
// 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.respond {
|
||||||
this.embeds.add(
|
this.embeds.add(
|
||||||
MessageUtil.getEmbed(
|
MessageUtil.getEmbed(
|
||||||
|
@ -110,7 +94,7 @@ class AwakeExtension : Extension() {
|
||||||
"Good morning, ${u.username}!",
|
"Good morning, ${u.username}!",
|
||||||
ud.customWakeupMessage.replace("#user", u.mention) + "\n" +
|
ud.customWakeupMessage.replace("#user", u.mention) + "\n" +
|
||||||
"\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" +
|
"${ud.coins} coin${if (ud.coins >= 1) "s" else ""} (+${streakCoins+1})\n" +
|
||||||
"lvl ${ud.level} (${ud.xp}/${neededXpForNextLvl} xp) [+${10 + bonusXp} xp]\n",
|
"lvl ${ud.level} (${ud.xp}/${neededXpForNextLvl} xp) [+${10 + bonusXp} xp]\n",
|
||||||
u.username,
|
u.username,
|
||||||
|
|
|
@ -25,11 +25,11 @@ import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
|
||||||
import com.kotlindiscord.kord.extensions.types.respond
|
import com.kotlindiscord.kord.extensions.types.respond
|
||||||
import dev.kord.common.entity.Snowflake
|
import dev.kord.common.entity.Snowflake
|
||||||
import dev.kord.core.entity.Guild
|
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.entry.UserData
|
||||||
import net.moonleay.bedge.data.database.repository.UserRepository
|
import net.moonleay.bedge.data.database.repository.UserRepository
|
||||||
import net.moonleay.bedge.extensions.component.ListTypes
|
import net.moonleay.bedge.extensions.component.ListTypes
|
||||||
import net.moonleay.bedge.util.EmbedColor
|
import net.moonleay.bedge.util.EmbedColor
|
||||||
import net.moonleay.bedge.util.Logger
|
|
||||||
import net.moonleay.bedge.util.MessageUtil
|
import net.moonleay.bedge.util.MessageUtil
|
||||||
|
|
||||||
class TopExtension : Extension() {
|
class TopExtension : Extension() {
|
||||||
|
@ -49,27 +49,22 @@ class TopExtension : Extension() {
|
||||||
val g = this.guild!!.asGuild()
|
val g = this.guild!!.asGuild()
|
||||||
val targetList = this.arguments.listType
|
val targetList = this.arguments.listType
|
||||||
val all = UserRepository.getAllUsers()
|
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) {
|
when(targetList) {
|
||||||
ListTypes.TOPSTREAK -> {
|
ListTypes.TOPSTREAK -> {
|
||||||
Logger.out("Sorting by topstreak")
|
allInGuild.sortedByDescending { it.longestStreak }
|
||||||
allInGuild = allInGuild.sortedByDescending { it.longestStreak }
|
|
||||||
}
|
}
|
||||||
ListTypes.STREAK -> {
|
ListTypes.STREAK -> {
|
||||||
Logger.out("Sorting by streak")
|
allInGuild.sortedByDescending { it.currentStreak }
|
||||||
allInGuild = allInGuild.sortedByDescending { it.currentStreak }
|
|
||||||
}
|
}
|
||||||
ListTypes.TOPCOINS -> {
|
ListTypes.TOPCOINS -> {
|
||||||
Logger.out("Sorting by topcoins")
|
allInGuild.sortedByDescending { it.coinsCollected }
|
||||||
allInGuild = allInGuild.sortedByDescending { it.coinsCollected }
|
|
||||||
}
|
}
|
||||||
ListTypes.COINS -> {
|
ListTypes.COINS -> {
|
||||||
Logger.out("Sorting by coins")
|
allInGuild.sortedByDescending { it.coins }
|
||||||
allInGuild = allInGuild.sortedByDescending { it.coins }
|
|
||||||
}
|
}
|
||||||
ListTypes.FAILS -> {
|
ListTypes.FAILS -> {
|
||||||
Logger.out("Sorting by fails")
|
allInGuild.sortedByDescending { it.numberOfFails }
|
||||||
allInGuild = allInGuild.sortedByDescending { it.numberOfFails }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var msg = ""
|
var msg = ""
|
||||||
|
@ -92,6 +87,7 @@ class TopExtension : Extension() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private suspend fun getRow(user: UserData, g: Guild, type: ListTypes): Array<String> {
|
private suspend fun getRow(user: UserData, g: Guild, type: ListTypes): Array<String> {
|
||||||
val typeResult: String = when(type) {
|
val typeResult: String = when(type) {
|
||||||
ListTypes.TOPSTREAK -> user.longestStreak.toString()
|
ListTypes.TOPSTREAK -> user.longestStreak.toString()
|
||||||
|
|
|
@ -47,7 +47,6 @@ class WakeupJob(override val jobName: String, override val jobIncoming: String,
|
||||||
val user = UserRepository.getUserByID(userId)
|
val user = UserRepository.getUserByID(userId)
|
||||||
if (!user.isAwake){
|
if (!user.isAwake){
|
||||||
// Failed
|
// Failed
|
||||||
val userasuser = Bot.bot.kordRef.getUser(Snowflake(userId))!!.asUser()
|
|
||||||
val brokenStreak = user.currentStreak
|
val brokenStreak = user.currentStreak
|
||||||
val isBiggestStreakYet = user.currentStreak > user.longestStreak
|
val isBiggestStreakYet = user.currentStreak > user.longestStreak
|
||||||
++user.numberOfFails
|
++user.numberOfFails
|
||||||
|
@ -62,11 +61,11 @@ class WakeupJob(override val jobName: String, override val jobIncoming: String,
|
||||||
MessageUtil.getEmbed(
|
MessageUtil.getEmbed(
|
||||||
EmbedColor.ERROR,
|
EmbedColor.ERROR,
|
||||||
"You failed to wake up!",
|
"You failed to wake up!",
|
||||||
"${userasuser.mention} failed to wake up at ${TimeUtil.getHourAndMinuteFromStamp(user.nextWakeup)}!\n" +
|
"You failed to wake up at ${TimeUtil.getHourAndMinuteFromStamp(user.nextWakeup)}!\n" +
|
||||||
"You lost a streak of $brokenStreak" +
|
"You lost a streak of ${user.currentStreak}" +
|
||||||
if(isBiggestStreakYet) ", which was your biggest streak yet." else "." +
|
if(isBiggestStreakYet) ", which was your biggest streak yet." else "." +
|
||||||
"\nYou can try again tomorrow with `/time`",
|
"\nYou can try again tomorrow with `/time`",
|
||||||
"Automated Message",
|
user.userid.toString(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue