Skip to content

Commit

Permalink
Update search provider arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Jul 18, 2023
1 parent 60b26d0 commit cad306b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ suspend fun MusicModule.playMessageAction() = ephemeralMessageCommand {
class PlayMessageActionArguments(override val query: String) : QueueOptions {
override val force: Boolean = false
override val top: Boolean = false
override val soundcloud: Boolean = false
override val searchProvider: QueueOptions.SearchProvider? = null
}

private suspend fun EphemeralMessageCommandContext<*>.queue(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,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
Expand All @@ -11,10 +12,9 @@ import dev.schlaubi.mikmusic.playlist.mapToEncoded

class PlaylistAddArguments : PlaylistArguments(), QueueOptions {
override val query by autoCompletedYouTubeQuery("commands.playlist.add.arguments.query.description")
override val soundcloud by defaultingBoolean {
name = "soundcloud"
description = "commands.playlist.add.arguments.soundscloud.description"
defaultValue = false
override val searchProvider: QueueOptions.SearchProvider? by optionalEnumChoice<QueueOptions.SearchProvider> {
name = "search-provider"
description = "The search provider to use"
}
val search by defaultingBoolean {
name = "search"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PlaylistSaveArguments : Arguments(), QueueOptions {
get() = importFrom ?: error("Cannot find tracks if importFrom is not specified")
override val force: Boolean = false
override val top: Boolean = false
override val soundcloud: Boolean = false
override val searchProvider: QueueOptions.SearchProvider? = null
}

fun PlaylistModule.saveCommand() = ephemeralSubCommand(::PlaylistSaveArguments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface QueueOptions {
val query: String
val force: Boolean
val top: Boolean
val search: SearchProvider?
val searchProvider: SearchProvider?

enum class SearchProvider(override val readableName: String, val prefix: String) : ChoiceEnum {
YouTube("YouTube", "ytsearch:"),
Expand All @@ -47,7 +47,7 @@ abstract class QueueArguments : Arguments(), QueueOptions {
description = "Adds this item to the top of the queueTracks"
defaultValue = false
}
override val search by optionalEnumChoice<QueueOptions.SearchProvider> {
override val searchProvider by optionalEnumChoice<QueueOptions.SearchProvider> {
name = "search-provider"
description = "Which searchprovider to use"
}
Expand Down Expand Up @@ -95,7 +95,7 @@ internal suspend fun CommandContext.findTracks(
val isUrl = urlProtocol.find(rawQuery) != null

val query = if (!isUrl) {
val searchPrefix = if (arguments.search != null) "${arguments.search?.prefix}" else "dzsearch:"
val searchPrefix = if (arguments.searchProvider != null) "${arguments.searchProvider?.prefix}" else "dzsearch:"

searchPrefix + rawQuery
} else rawQuery
Expand Down

0 comments on commit cad306b

Please sign in to comment.