Skip to content

Commit

Permalink
fix bad lyrics command logic
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Apr 28, 2024
1 parent 6525794 commit d8ae1d7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions commands/lyrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ import (
func (c *Commands) Lyrics(data discord.SlashCommandInteractionData, e *handler.CommandEvent) error {
skipTrackSource := data.Bool("skip-track-source")

if err := e.DeferCreateMessage(false); err != nil {
return err
}

var (
track string
lyrics *lavalyrics.Lyrics
Expand All @@ -28,10 +24,13 @@ func (c *Commands) Lyrics(data discord.SlashCommandInteractionData, e *handler.C

ctx, cancel := context.WithTimeout(e.Ctx, 10*time.Second)
defer cancel()

if encodedTrack, ok := data.OptString("track"); ok {
track = fmt.Sprintf("`%s`", encodedTrack)

if err = e.DeferCreateMessage(false); err != nil {
return err
}

lyrics, err = lavalyrics.GetLyrics(ctx, c.Lavalink.BestNode().Rest(), encodedTrack, skipTrackSource)
} else {
player := c.Lavalink.ExistingPlayer(*e.GuildID())
Expand All @@ -52,6 +51,10 @@ func (c *Commands) Lyrics(data discord.SlashCommandInteractionData, e *handler.C

track = res.FormatTrack(*playingTrack, 0)

if err = e.DeferCreateMessage(false); err != nil {
return err
}

lyrics, err = lavalyrics.GetCurrentTrackLyrics(ctx, player.Node().Rest(), player.Node().SessionID(), *e.GuildID(), skipTrackSource)
}
if err != nil {
Expand Down

0 comments on commit d8ae1d7

Please sign in to comment.