package commands import ( "context" "fmt" "strings" "github.com/disgoorg/disgo/discord" "github.com/disgoorg/disgo/events" ) type QueueCommand struct { deps *Dependencies } func NewQueueCommand(deps *Dependencies) *QueueCommand { return &QueueCommand{deps: deps} } func (c *QueueCommand) Definition() discord.ApplicationCommandCreate { return discord.SlashCommandCreate{ Name: "queue", Description: "Shows the upcoming tracks", } } func (c *QueueCommand) Execute(ctx context.Context, event *events.ApplicationCommandInteractionCreate) error { gid, ok := guildID(event) if !ok { return guildOnlyError(event) } tracks := c.deps.Music.Guild(gid).Queued() if len(tracks) == 0 { return reply(event, "The queue is empty.") } var builder strings.Builder builder.WriteString("Up next:\n") for i, track := range tracks { fmt.Fprintf(&builder, "%d. **%s** (%s)\n", i+1, track.Info.Title, track.Info.Length) } return reply(event, builder.String()) }