Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
- Fix issue with command registering with volume option
- Fix issue with error handler
- Add translations for volume
- Fix wrong argument name
  • Loading branch information
DRSchlaubi committed Aug 29, 2023
1 parent 9bd0254 commit de6f06e
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion app/desktop/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import dev.schlaubi.tonbrett.app.title
import dev.schlaubi.tonbrett.client.href
import dev.schlaubi.tonbrett.common.Route
import io.ktor.http.*
import io.ktor.serialization.ContentConvertException
import mu.KotlinLogging
import java.net.URI
import kotlin.system.exitProcess
Expand Down Expand Up @@ -152,7 +153,7 @@ private class ExceptionHandlerFactory(val handler: (Throwable) -> Unit) : Window
private inner class ExceptionHandler(val window: AWTWindow) : WindowExceptionHandler {
@OptIn(ExperimentalComposeUiApi::class)
override fun onException(throwable: Throwable) {
if (throwable is IllegalArgumentException) {
if (throwable is IllegalArgumentException || throwable is ContentConvertException) {
handler(throwable)
} else {
DefaultWindowExceptionHandlerFactory.exceptionHandler(window).onException(throwable)
Expand Down
17 changes: 14 additions & 3 deletions app/shared/src/commonMain/kotlin/TonbrettApp.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package dev.schlaubi.tonbrett.app

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Icon
import androidx.compose.material.SnackbarHost
import androidx.compose.material.icons.Icons
Expand All @@ -11,7 +16,13 @@ import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.intl.Locale
Expand Down Expand Up @@ -61,7 +72,7 @@ fun TonbrettApp(sessionExpiredState: MutableState<Boolean> = remember { mutableS
initialUser = context.api.getMe()
} catch (e: ClientRequestException) {
if (e.response.status.value in 400..499) {
reportError(ReauthorizationRequiredException())
reportError(ReauthorizationRequiredException())
}
} catch (e: ReauthorizationRequiredException) {
reportError(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class UpdateSoundArguments : Arguments() {
}

val volume by optionalInt {
name = "public"
name = "volume"
description = "commands.update_sound.arguments.volume.description"
minValue = 0
maxValue = 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import dev.schlaubi.tonbrett.bot.util.player
import dev.schlaubi.tonbrett.common.InterfaceAvailabilityChangeEvent
import dev.schlaubi.tonbrett.common.Snowflake
import dev.schlaubi.tonbrett.common.Sound
import io.ktor.http.*
import kotlinx.coroutines.*
import io.ktor.http.path
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.single
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.launch
import kotlin.coroutines.CoroutineContext
import kotlin.io.path.fileVisitor

private val players = mutableMapOf<Snowflake, SoundPlayer>()

Expand Down Expand Up @@ -74,7 +77,7 @@ class SoundPlayer(guild: GuildBehavior) : CoroutineScope {
player.injectTrack(url, noReplace = alreadyLocked) {
filters {
if (sound.volume != null) {
volume = sound.volume!!.toFloat()
volume = (sound.volume!!.toFloat() / 2.0f / 100.0f)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ commands.add_sound.arguments.tag.description=Ein optionaler tag, um ähnliches s
commands.update_sound.arguments.tag.description=Der neue Tag von dieser Audio
commands.update_sound.arguments.public.description=Ob diese Audio öffentlich sein soll
commands.add_sound.arguments.public.description=Ob diese Audio öffentlich sein soll
commands.add_sound.arguments.volume.description=Die Lautstärke in der die Audio abgespielt werden soll
commands.update_sound.arguments.volume.description=Die Lautstärke in der die Audio abgespielt werden soll
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ commands.add_sound.arguments.tag.description=An optional tag for the sound to gr
commands.update_sound.arguments.tag.description=The new tag of the sound
commands.update_sound.arguments.public.description=Whether this command should be public
commands.add_sound.arguments.public.description=Whether this command should be public
commands.add_sound.arguments.volume.description=The volume of the audio
commands.update_sound.arguments.volume.description=The volume of the audio
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {

allprojects {
group = "dev.schlaubi.tonbrett"
version = "1.12.15"
version = "1.12.17"

repositories {
mavenCentral()
Expand Down

0 comments on commit de6f06e

Please sign in to comment.