Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added search if Play command is used without a URL #32

Closed
wants to merge 1 commit into from

Conversation

mihai-bocioroaga
Copy link

Addresses #14

Primitive implementation just to get the functionality added. Similar to how some other bots overload their Play command.

@@ -20,8 +22,14 @@ class PlayCommand(
) : Command("play", "p") {
override suspend fun CommandContext.invoke() {
if (!ensureVoiceChannel()) return
val identifier = argumentText
apm.loadItem(identifier, Loader(this, player, identifier))
var identifier = argumentText
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified a lot. Using exception handling as control flow is an antipattern.

val identifier = if(argumentText.startsWith("http")) argumentText else "ytsearch:$identifier"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was initially my solution, but I feel like it's a bit of a cheat and a more robust solution would cover the unlikely but still possible scenario where someone tries to play something starting with 'http'. Worth thinking about.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more robust solution would be argumentText.startsWith("http://") || argumentText.startsWith("https://")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't argue with that now 😄

@jocull
Copy link
Contributor

jocull commented Oct 21, 2021

This branch is a welcome addition! I was searching for this functionality today, lamenting that I was going to have to implement it myself. I pulled your branch and it's running happily now on a Raspberry Pi 4 😄

Thanks a lot for Ukulele and this addition!

@jocull
Copy link
Contributor

jocull commented Oct 25, 2021

Conflicts for this are resolved at jocull:search

@lexisother
Copy link

I hope @bUbirz won't mind me bumping this.

@jocull
Copy link
Contributor

jocull commented Apr 21, 2022

These changes were brought in under #53 so this PR may now be a duplicate to close 🙂

@freyacodes freyacodes closed this Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants