handling empty command, fixing #3
This commit is contained in:
+18
-3
@@ -101,8 +101,22 @@ It is not planned to extend this in the future.`,
|
||||
err = viper.WriteConfig()
|
||||
cobra.CheckErr(err)
|
||||
}
|
||||
results, err := client.Search(ctx, strings.TrimPrefix(update.Message.Text, "/spotigram "), spotify.SearchTypeTrack)
|
||||
cobra.CheckErr(err)
|
||||
|
||||
var results *spotify.SearchResult
|
||||
|
||||
if strings.HasPrefix(update.Message.Text, "/spotigram ") {
|
||||
results, err = client.Search(ctx, strings.TrimPrefix(update.Message.Text, "/spotigram "), spotify.SearchTypeTrack)
|
||||
cobra.CheckErr(err)
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(update.Message.Text, "/spotigram ") {
|
||||
msg.Text = "⛔ Ooops, du musst einen Titel angeben!\n <code>/spotigram [Titel]</code>"
|
||||
msg.ParseMode = "HTML"
|
||||
_, err = bot.Send(msg)
|
||||
cobra.CheckErr(err)
|
||||
|
||||
fmt.Printf("Command used incorrectly.")
|
||||
}
|
||||
|
||||
if results != nil {
|
||||
|
||||
@@ -145,7 +159,8 @@ It is not planned to extend this in the future.`,
|
||||
track.Name,
|
||||
track.Artists[0].Name)
|
||||
|
||||
} else {
|
||||
}
|
||||
if !contains(trackIDs, results.Tracks.Tracks[0].ID) {
|
||||
track := results.Tracks.Tracks[0]
|
||||
|
||||
addTrackResponse, err := client.AddTracksToPlaylist(ctx,
|
||||
|
||||
Reference in New Issue
Block a user