38 lines
903 B
Go
38 lines
903 B
Go
package commands
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/disgoorg/disgo/discord"
|
|
"github.com/disgoorg/disgo/events"
|
|
)
|
|
|
|
type NowPlayingCommand struct {
|
|
deps *Dependencies
|
|
}
|
|
|
|
func NewNowPlayingCommand(deps *Dependencies) *NowPlayingCommand {
|
|
return &NowPlayingCommand{deps: deps}
|
|
}
|
|
|
|
func (c *NowPlayingCommand) Definition() discord.ApplicationCommandCreate {
|
|
return discord.SlashCommandCreate{
|
|
Name: "nowplaying",
|
|
Description: "Shows the currently playing track",
|
|
}
|
|
}
|
|
|
|
func (c *NowPlayingCommand) Execute(ctx context.Context, event *events.ApplicationCommandInteractionCreate) error {
|
|
gid, ok := guildID(event)
|
|
if !ok {
|
|
return guildOnlyError(event)
|
|
}
|
|
|
|
track, playing := c.deps.Music.Guild(gid).NowPlaying()
|
|
if !playing {
|
|
return reply(event, "Nothing is playing right now.")
|
|
}
|
|
return reply(event, fmt.Sprintf("Now playing: **%s** (%s)", track.Info.Title, track.Info.Length))
|
|
}
|