Skip to content

Commit

Permalink
Bump mikbot
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Jul 19, 2023
1 parent 0dfc44d commit 187dd37
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
5 changes: 3 additions & 2 deletions bot/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import dev.schlaubi.mikbot.gradle.mikbot
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand All @@ -18,9 +19,8 @@ dependencies {
ktorDependency(libs.ktor.server.cors)
ktorDependency(libs.ktor.server.auth.jwt)
implementation(libs.kmongo.id.serialization)
plugin(libs.mikbot.ktor)
plugin(mikbot(libs.mikbot.ktor))
plugin(libs.mikbot.music)
ksp(libs.kordex.processor)
}

fun DependencyHandlerScope.ktorDependency(dependency: ProviderConvertible<*>) = ktorDependency(dependency.asProvider())
Expand All @@ -32,6 +32,7 @@ mikbotPlugin {
provider = "Schlaubi"
pluginId = "tonbrett"
license = "MIT"
enableKordexProcessor = true
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package dev.schlaubi.tonbrett.bot.commands
import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.converters.impl.*
import com.kotlindiscord.kord.extensions.types.respond
import dev.arbjerg.lavalink.protocol.v4.LoadResult
import dev.schlaubi.lavakord.rest.loadItem
import dev.schlaubi.lavakord.rest.models.TrackResponse
import dev.schlaubi.mikbot.plugin.api.module.SubCommandModule
import dev.schlaubi.mikbot.plugin.api.util.kord
import dev.schlaubi.mikbot.plugin.api.util.safeGuild
Expand Down Expand Up @@ -77,13 +77,14 @@ fun SubCommandModule.addCommand() = ephemeralSubCommand(::AddSoundCommandArgumen

@Suppress("INVISIBLE_MEMBER")
val audioInfo = safeGuild.player.link.loadItem(arguments.sound.url)
if (audioInfo.loadType != TrackResponse.LoadType.TRACK_LOADED) {
if (audioInfo !is LoadResult.TrackLoaded) {
respond {
content = translate("commands.add_sound.invalid_file", arrayOf(audioInfo.exception?.message))
val message = (audioInfo as? LoadResult.LoadFailed)?.data?.message
content = translate("commands.add_sound.invalid_file", arrayOf(message))
}
return@action
}
if (audioInfo.track.info.length.toDuration(DurationUnit.MILLISECONDS) > Config.MAX_SOUND_LENGTH) {
if (audioInfo.data.info.length.toDuration(DurationUnit.MILLISECONDS) > Config.MAX_SOUND_LENGTH) {
respond {
content = translate("commands.add_sound.too_long", arrayOf(Config.MAX_SOUND_LENGTH))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.schlaubi.tonbrett.bot.core

import dev.arbjerg.lavalink.protocol.v4.Message
import dev.kord.core.behavior.GuildBehavior
import dev.schlaubi.lavakord.audio.TrackEndEvent
import dev.schlaubi.mikbot.util_plugins.ktor.api.buildBotUrl
Expand Down Expand Up @@ -75,7 +76,7 @@ class SoundPlayer(guild: GuildBehavior) : CoroutineScope {
// Wait for track to end
player.player.events
.filterIsInstance<TrackEndEvent>()
.filter { it.reason != TrackEndEvent.EndReason.REPLACED }
.filter { it.reason != Message.EmittedEvent.TrackEndEvent.AudioTrackEndReason.REPLACED }
.take(1)
.single()
locked = false
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {

allprojects {
group = "dev.schlaubi.tonbrett"
version = "1.10.9"
version = "1.11.0"

repositories {
mavenCentral()
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kotlin = "1.8.20"
ktor = "2.3.2"
kmongo = "4.9.0"
kord = "0.9.0"
mikbot = "3.18.0"
mikbot = "3.20.0"
ksp = "1.8.20-1.0.10"
kordex = "1.5.7-SNAPSHOT"
android = "8.0.2"
Expand Down Expand Up @@ -38,7 +38,7 @@ ktor-client-auth = { group = "io.ktor", name = "ktor-client-auth", version.ref =
ktor-serialization-kotlinx-json = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktor" }

mikbot-ktor = { group = "dev.schlaubi", name = "mikbot-ktor", version.ref = "mikbot" }
mikbot-music = { group = "dev.schlaubi", name = "mikbot-player", version = "2.23.0-SNAPSHOT" }
mikbot-music = { group = "dev.schlaubi", name = "mikbot-music-player", version = "3.0.0-SNAPSHOT" }

imageloader = { group = "io.github.qdsfdhvh", name = "image-loader", version = "1.4.2" }

Expand Down

0 comments on commit 187dd37

Please sign in to comment.