Skip to content

Commit

Permalink
Fix build and use K2 & Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Nov 1, 2023
1 parent 28d4947 commit b27e72a
Show file tree
Hide file tree
Showing 50 changed files with 39 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions: write-all

jobs:
mikbot:
uses: mikbot/mikbot-workflow/.github/workflows/mikbot-workflow.yml@v1.3.1
uses: mikbot/mikbot-workflow/.github/workflows/mikbot-workflow.yml@v1.4.0
with:
run-maven-publish: true
update-binary-repository: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gradle_plugin_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ jobs:
needs: gradleValidation
steps:
- uses: actions/checkout@v3
- name: Set up JDK 19
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 19
java-version: 21
- name: Test with Gradle
run: ./gradlew gradle-plugin:classes
- name: Login to Gradle Plugin Portal
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM eclipse-temurin:20-jre-alpine
FROM eclipse-temurin:21-jre-alpine

WORKDIR /usr/app
COPY runtime/build/install/mikmusic ./
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.kotlindiscord.kord.extensions.modules.unsafe.annotations.UnsafeAPI
import com.kotlindiscord.kord.extensions.modules.unsafe.contexts.UnsafeSlashCommandContext
import com.kotlindiscord.kord.extensions.modules.unsafe.types.respondEphemeral
import com.kotlindiscord.kord.extensions.modules.unsafe.types.respondPublic
import com.kotlindiscord.kord.extensions.types.respond
import com.kotlindiscord.kord.extensions.utils.waitFor
import dev.kord.common.entity.ButtonStyle
import dev.kord.core.behavior.interaction.followup.FollowupMessageBehavior
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import com.kotlindiscord.kord.extensions.pagination.builders.PaginatorBuilder
import dev.kord.core.behavior.UserBehavior
import dev.kord.rest.builder.message.EmbedBuilder
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.flow.toList
import kotlin.math.ceil

Expand All @@ -21,14 +19,14 @@ import kotlin.math.ceil
* @param additionalConfig additional [PaginatorBuilder] config
* @param additionalPageConfig additional [EmbedBuilder] config, applied to each page
*/
public suspend fun <T> PaginatorBuilder.forList(
public fun <T> PaginatorBuilder.forList(
user: UserBehavior,
items: List<T>,
mapper: suspend (T) -> String,
title: suspend (current: Int, total: Int) -> String,
chunkSize: Int = 8,
enumerate: Boolean = true,
additionalConfig: suspend PaginatorBuilder.() -> Unit = {},
additionalConfig: PaginatorBuilder.() -> Unit = {},
additionalPageConfig: suspend EmbedBuilder.() -> Unit = {},
): Unit = forList(user, items.size, { offset, limit ->
items.subList(offset, (offset + limit).coerceAtMost(items.size))
Expand All @@ -55,21 +53,31 @@ public suspend fun <T> PaginatorBuilder.forFlow(
title: suspend (current: Int, total: Int) -> String,
chunkSize: Int = 8,
enumerate: Boolean = true,
additionalConfig: suspend PaginatorBuilder.() -> Unit = {},
additionalConfig: PaginatorBuilder.() -> Unit = {},
additionalPageConfig: suspend EmbedBuilder.() -> Unit = {},
): Unit = forList(user, total.toInt(), { offset, _ ->
items.drop(offset).take(chunkSize).toList()
}, mapper, title, chunkSize, enumerate, additionalConfig, additionalPageConfig)
) {
val list = items.toList()
forList(
user,
list,
mapper,
title,
chunkSize,
enumerate,
additionalConfig,
additionalPageConfig
)
}

private suspend fun <T> PaginatorBuilder.forList(
private fun <T> PaginatorBuilder.forList(
user: UserBehavior,
size: Int,
subList: suspend (offset: Int, limit: Int) -> List<T>,
subList: (offset: Int, limit: Int) -> List<T>,
mapper: suspend (T) -> String,
title: suspend (current: Int, end: Int) -> String,
chunkSize: Int = 8,
enumerate: Boolean = true,
additionalConfig: suspend PaginatorBuilder.() -> Unit = {},
additionalConfig: PaginatorBuilder.() -> Unit = {},
additionalPageConfig: suspend EmbedBuilder.() -> Unit = {},
) {
owner = user
Expand All @@ -92,7 +100,7 @@ private fun <T> PaginatorBuilder.addPage(
items: List<T>,
enumerate: Boolean,
mapper: suspend (T) -> String,
additionalPageConfig: suspend EmbedBuilder.() -> Unit
additionalPageConfig: suspend EmbedBuilder.() -> Unit,
) {
page {
this.title = title((myOffset + 1), pages.groups.size)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.schlaubi.mikbot.plugin.api.util

import com.kotlindiscord.kord.extensions.commands.CommandContext
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.core.behavior.interaction.followup.FollowupMessageBehavior
import dev.kord.rest.builder.message.create.MessageCreateBuilder
import dev.kord.rest.builder.message.modify.MessageModifyBuilder
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/mikbot-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ tasks {
}

kotlin {
jvmToolchain(20)
jvmToolchain(21)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.application.slash.converters.impl.stringChoice
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.kotlindiscord.kord.extensions.i18n.SupportedLocales
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikbot.core.i18n.database.LangaugeUser
import dev.schlaubi.mikbot.core.i18n.database.LanguageDatabase
import dev.schlaubi.mikbot.plugin.api.settings.SettingsModule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.schlaubi.mikbot.core.gdpr

import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikbot.plugin.api.util.confirmation

fun GDPRModule.deleteCommand() = ephemeralSubCommand {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.schlaubi.mikbot.core.gdpr

import com.kotlindiscord.kord.extensions.commands.CommandContext
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.rest.builder.message.EmbedBuilder
import dev.kord.rest.builder.message.create.embed
import dev.schlaubi.mikbot.core.gdpr.api.AnonymizedData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.schlaubi.mikbot.core.gdpr

import com.kotlindiscord.kord.extensions.types.editingPaginator
import dev.kord.rest.builder.message.EmbedBuilder
import dev.schlaubi.mikbot.plugin.api.util.effectiveAvatar
import dev.schlaubi.stdx.core.paginate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dev.schlaubi.mikbot.core.redeploy_hook

import com.kotlindiscord.kord.extensions.commands.application.slash.EphemeralSlashCommandContext
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikbot.core.redeploy_hook.api.RedeployExtensionPoint
import dev.schlaubi.mikbot.plugin.api.getExtensions
import dev.schlaubi.mikbot.plugin.api.owner.OwnerModule
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ kotlin.code.style=official
org.gradle.parallel=true
kotlin.mpp.stability.nowarn=true
org.gradle.caching=true
kotlin.experimental.tryK2=true
2 changes: 1 addition & 1 deletion music/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
subprojects {
version = "3.1.10-SNAPSHOT"
version = "3.2.0-SNAPSHOT"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.schlaubi.mikmusic.commands

import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikmusic.core.MusicModule

suspend fun MusicModule.clearCommand() = ephemeralControlSlashCommand {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.schlaubi.mikmusic.commands

import com.kotlindiscord.kord.extensions.commands.application.slash.EphemeralSlashCommandContext
import com.kotlindiscord.kord.extensions.types.edit
import com.kotlindiscord.kord.extensions.utils.waitFor
import dev.kord.common.entity.ButtonStyle
import dev.kord.common.entity.Permission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package dev.schlaubi.mikmusic.commands
import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.converters.impl.optionalString
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.editingPaginator
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikbot.plugin.api.util.forList
import dev.schlaubi.mikmusic.checks.musicQuizAntiCheat
import dev.schlaubi.mikmusic.core.MusicModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.kotlindiscord.kord.extensions.commands.application.slash.EphemeralSla
import com.kotlindiscord.kord.extensions.commands.application.slash.EphemeralSlashCommandContext
import com.kotlindiscord.kord.extensions.commands.application.slash.ephemeralSubCommand
import com.kotlindiscord.kord.extensions.commands.converters.impl.int
import com.kotlindiscord.kord.extensions.types.respond
import dev.arbjerg.lavalink.protocol.v4.Track
import dev.schlaubi.mikmusic.core.MusicModule

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.schlaubi.mikmusic.commands

import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikmusic.checks.anyMusicPlaying
import dev.schlaubi.mikmusic.core.MusicModule
import dev.schlaubi.mikmusic.player.ChapterQueuedTrack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dev.schlaubi.mikmusic.commands
import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.converters.impl.optionalInt
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.rest.builder.message.create.embed
import dev.schlaubi.mikmusic.checks.anyMusicPlaying
import dev.schlaubi.mikmusic.checks.musicQuizAntiCheat
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.schlaubi.mikmusic.commands

import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikmusic.core.MusicModule

suspend fun MusicModule.pauseCommand() = ephemeralControlSlashCommand {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package dev.schlaubi.mikmusic.commands

import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.kotlindiscord.kord.extensions.types.editingPaginator
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikbot.plugin.api.util.forList
import dev.schlaubi.mikmusic.checks.anyMusicPlaying
import dev.schlaubi.mikmusic.core.MusicModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.kotlindiscord.kord.extensions.commands.application.slash.EphemeralSla
import com.kotlindiscord.kord.extensions.commands.application.slash.EphemeralSlashCommandContext
import com.kotlindiscord.kord.extensions.commands.application.slash.ephemeralSubCommand
import com.kotlindiscord.kord.extensions.commands.converters.impl.int
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.common.entity.Snowflake
import dev.schlaubi.mikbot.plugin.api.util.safeGuild
import dev.schlaubi.mikmusic.core.MusicModule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.schlaubi.mikmusic.commands

import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikmusic.core.MusicModule

suspend fun MusicModule.replayCommand() = ephemeralControlSlashCommand {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.schlaubi.mikmusic.commands

import com.kotlindiscord.kord.extensions.commands.application.slash.EphemeralSlashCommandContext
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikmusic.core.MusicModule
import dev.schlaubi.mikmusic.player.MusicPlayer
import kotlin.reflect.KMutableProperty1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.kotlindiscord.kord.extensions.DiscordRelayedException
import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.converters.impl.string
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikmusic.checks.anyMusicPlaying
import dev.schlaubi.mikmusic.core.MusicModule
import kotlin.time.Duration.Companion.minutes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dev.schlaubi.mikmusic.commands

import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.converters.impl.defaultingInt
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikmusic.core.MusicModule

class SkipArguments : Arguments() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.schlaubi.mikmusic.commands

import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikmusic.core.MusicModule

suspend fun MusicModule.stopCommand() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dev.schlaubi.mikmusic.commands
import com.kotlindiscord.kord.extensions.DiscordRelayedException
import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.converters.impl.optionalInt
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikmusic.core.MusicModule

class VolumeArguments : Arguments() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package dev.schlaubi.mikmusic.context

import com.kotlindiscord.kord.extensions.commands.application.message.EphemeralMessageCommandContext
import com.kotlindiscord.kord.extensions.extensions.ephemeralMessageCommand
import com.kotlindiscord.kord.extensions.types.editingPaginator
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikbot.plugin.api.util.attachmentOrContentQuery
import dev.schlaubi.mikmusic.checks.joinSameChannelCheck
import dev.schlaubi.mikmusic.core.MusicModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dev.schlaubi.mikmusic.core.settings.commands
import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.converters.impl.optionalRole
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikbot.plugin.api.settings.SettingsModule
import dev.schlaubi.mikbot.plugin.api.settings.guildAdminOnly
import dev.schlaubi.mikbot.plugin.api.util.safeGuild
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.schlaubi.mikmusic.core.settings.commands

import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikbot.plugin.api.settings.SettingsModule
import dev.schlaubi.mikbot.plugin.api.util.safeGuild
import dev.schlaubi.mikmusic.core.settings.MusicSettingsDatabase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.kotlindiscord.kord.extensions.DiscordRelayedException
import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.converters.impl.duration
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikbot.plugin.api.settings.SettingsModule
import dev.schlaubi.mikbot.plugin.api.settings.guildAdminOnly
import dev.schlaubi.mikbot.plugin.api.util.safeGuild
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.application.slash.EphemeralSlashCommandContext
import com.kotlindiscord.kord.extensions.commands.converters.impl.optionalInt
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikbot.plugin.api.settings.SettingsModule
import dev.schlaubi.mikbot.plugin.api.settings.guildAdminOnly
import dev.schlaubi.mikbot.plugin.api.util.safeGuild
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dev.schlaubi.mikmusic.core.settings.commands
import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.converters.impl.optionalBoolean
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.lavakord.plugins.sponsorblock.model.Category
import dev.schlaubi.lavakord.plugins.sponsorblock.rest.disableSponsorblock
import dev.schlaubi.lavakord.plugins.sponsorblock.rest.putSponsorblockCategories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dev.schlaubi.mikmusic.playlist.commands

import com.kotlindiscord.kord.extensions.commands.application.slash.converters.impl.optionalEnumChoice
import com.kotlindiscord.kord.extensions.commands.converters.impl.defaultingBoolean
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.rest.builder.message.create.embed
import dev.schlaubi.mikmusic.autocomplete.autoCompletedYouTubeQuery
import dev.schlaubi.mikmusic.player.queue.QueueOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.CommandContext
import com.kotlindiscord.kord.extensions.commands.application.slash.EphemeralSlashCommandContext
import com.kotlindiscord.kord.extensions.commands.converters.impl.string
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.core.behavior.UserBehavior
import dev.schlaubi.mikbot.plugin.api.PluginContext
import dev.schlaubi.mikbot.plugin.api.module.SubCommandModule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.schlaubi.mikmusic.playlist.commands

import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikmusic.playlist.PlaylistDatabase

class PlaylistDeleteArguments : PlaylistArguments()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package dev.schlaubi.mikmusic.playlist.commands

import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.converters.impl.defaultingBoolean
import com.kotlindiscord.kord.extensions.types.editingPaginator
import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikbot.plugin.api.util.forFlow
import dev.schlaubi.mikbot.plugin.api.util.forList
import dev.schlaubi.mikmusic.playlist.Playlist
import dev.schlaubi.mikmusic.playlist.PlaylistDatabase
import org.litote.kmongo.eq
Expand Down Expand Up @@ -38,12 +36,12 @@ fun PlaylistModule.listCommand() = ephemeralSubCommand(::PlayListListArguments)
}
return@action
}
val playlists = PlaylistDatabase.collection.find(filter).toFlow()
val playlists = PlaylistDatabase.collection.find(filter).toList()

val tracks = translate("music.general.tracks")
editingPaginator {
forFlow(
user, playlistCount, playlists, { "${it.name} - ${it.songs.size} $tracks by <@${it.authorId}>" },
forList(
user, playlists, { "${it.name} - ${it.songs.size} $tracks by <@${it.authorId}>" },
{ current, total ->
translate(
"commands.playlist.list.paginator.title",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.schlaubi.mikmusic.playlist.commands

import com.kotlindiscord.kord.extensions.types.respond
import dev.schlaubi.mikmusic.checks.joinSameChannelCheck
import dev.schlaubi.mikmusic.playlist.PlaylistDatabase
import dev.schlaubi.mikmusic.util.mapToQueuedTrack
Expand Down
Loading

0 comments on commit b27e72a

Please sign in to comment.