package main

import (
	"fmt"
	"log"

	"github.com/nicklaw5/helix/v2"
)

// getFollowedLive prints details about channels the user is following that
// are live.  Currently auth is expected to be handled by the caller.  The
// passed client should be ready to go.  uid is just the user id string.
// XXX: Should maybe do at least scope handling here in the future.
func getFollowedLive(client *helix.Client, uid string) error {
	resp, err := client.GetFollowedStream(&helix.FollowedStreamsParams{
		UserID: uid,
	})

	if err != nil {
		log.Fatalf("Error getting followed streams: %v\n", err)
		return err
	}

	// TODO: Pagination and such
	for _, stream := range resp.Data.Streams {
		fmt.Printf("%v streaming %v for %v viewers since %v\n%v\n\n",
			stream.UserName, stream.GameName, stream.ViewerCount,
			stream.StartedAt, stream.Title)
	}

	return nil
}
