Skip to content

Commit

Permalink
update lyrics command
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Dec 29, 2023
1 parent 78db63e commit 454215b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions commands/lyrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ import (
"github.com/disgoorg/disgo/handler"
"github.com/disgoorg/json"
"github.com/disgoorg/lavalyrics-plugin"
"github.com/lavalink-devs/lavalink-bot/internal/res"
)

func (c *Commands) Lyrics(e *handler.CommandEvent) error {
player := c.Lavalink.ExistingPlayer(*e.GuildID())
track := player.Track()
if track == nil {
return e.CreateMessage(discord.MessageCreate{
Content: "no track playing",
Flags: discord.MessageFlagEphemeral,
})
}
if err := e.DeferCreateMessage(false); err != nil {
return err
}
Expand All @@ -39,6 +48,7 @@ func (c *Commands) Lyrics(e *handler.CommandEvent) error {
}

_, err = e.UpdateInteractionResponse(discord.MessageUpdate{
Content: json.Ptr(fmt.Sprintf("Loaded lyrics for %s from `%s`", res.FormatTrack(*track, 0), lyrics.SourceName)),
Files: []*discord.File{
discord.NewFile("lyrics.txt", "", bytes.NewReader([]byte(content))),
},
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/disgoorg/disgo v0.17.0
github.com/disgoorg/disgolink/v3 v3.0.0
github.com/disgoorg/json v1.1.0
github.com/disgoorg/lavalyrics-plugin v0.0.0-20231229185924-a5de9eaf4fd2
github.com/disgoorg/lavalyrics-plugin v0.0.0-20231229215219-9dfb609a0968
github.com/disgoorg/lavasearch-plugin v1.0.1-0.20231229185935-76caa6d35100
github.com/disgoorg/lavasrc-plugin v1.0.0
github.com/disgoorg/snowflake/v2 v2.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ github.com/disgoorg/disgolink/v3 v3.0.0 h1:rresswQhYRu/L9Ly0pm/ALM8ApTcN/ejspABq
github.com/disgoorg/disgolink/v3 v3.0.0/go.mod h1:YIwjIteZcjfI7HYZWH241iRI7RjTLoN51HLDOUHVSFI=
github.com/disgoorg/json v1.1.0 h1:7xigHvomlVA9PQw9bMGO02PHGJJPqvX5AnwlYg/Tnys=
github.com/disgoorg/json v1.1.0/go.mod h1:BHDwdde0rpQFDVsRLKhma6Y7fTbQKub/zdGO5O9NqqA=
github.com/disgoorg/lavalyrics-plugin v0.0.0-20231229185924-a5de9eaf4fd2 h1:aZKHFGYkTLGYvMQoTHkSWIlQW+SWtDe0hEGSfwy2B/4=
github.com/disgoorg/lavalyrics-plugin v0.0.0-20231229185924-a5de9eaf4fd2/go.mod h1:xoVKtS9skWr9OF2NgPPjv9ejuYXJ5RLcfMf7hTr6MWY=
github.com/disgoorg/lavalyrics-plugin v0.0.0-20231229215219-9dfb609a0968 h1:DghJgly/S/4Ekr3x3DmK6GPvmiII1uEclC7Tp/an6Hk=
github.com/disgoorg/lavalyrics-plugin v0.0.0-20231229215219-9dfb609a0968/go.mod h1:xoVKtS9skWr9OF2NgPPjv9ejuYXJ5RLcfMf7hTr6MWY=
github.com/disgoorg/lavasearch-plugin v1.0.1-0.20231229185935-76caa6d35100 h1:lmibrw2MBBZ+vyKHzlJ01MvLz16jiCQAJ6Qm/j3Al70=
github.com/disgoorg/lavasearch-plugin v1.0.1-0.20231229185935-76caa6d35100/go.mod h1:SjlXMsCmXImKOKVYpElcr8Ogbwt7L1BGYemCwt+Ld4I=
github.com/disgoorg/lavasrc-plugin v1.0.0 h1:FMQ8igQgIeP9rWX+YxjMtJCrWz8nCY0kLb2c/6n0Dpo=
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ func main() {
r.Route("/music", func(r handler.Router) {
r.Command("/play", cmds.Play)
r.Command("/tts", cmds.TTS)
r.Command("/lyrics", cmds.Lyrics)
r.Autocomplete("/play", cmds.PlayAutocomplete)
r.Group(func(r handler.Router) {
r.Use(cmds.RequirePlayer)
r.Command("/lyrics", cmds.Lyrics)

r.Command("/stop", cmds.Stop)
r.Command("/disconnect", cmds.Disconnect)
Expand Down

0 comments on commit 454215b

Please sign in to comment.