Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get a list of online clients or channels #41

Open
eiqnepm opened this issue Mar 24, 2023 · 1 comment
Open

Unable to get a list of online clients or channels #41

eiqnepm opened this issue Mar 24, 2023 · 1 comment

Comments

@eiqnepm
Copy link

eiqnepm commented Mar 24, 2023

I'm trying to query a server as a guest to get a list of clients and or channels. I'm probably missing something, however I just get the error invalid serverID (1024).

main.go
package main

import (
	"log"
	"os"

	"github.com/multiplay/go-ts3"
)

func main() {
	addr := os.Getenv("ADDR")

	c, err := ts3.NewClient(addr)
	if err != nil {
		log.Fatal(err)
	}
	defer func(c *ts3.Client) {
		err := c.Close()
		if err != nil {
			log.Println(err)
		}
	}(c)

	if v, err := c.Version(); err != nil {
		log.Fatal(err)
	} else {
		log.Println(v)
	}

	clients, err := c.Server.ClientList()
	if err != nil {
		log.Fatal(err)
	}

	for _, client := range clients {
		log.Println(client.Nickname)
	}
}
@stevenh
Copy link
Contributor

stevenh commented Mar 27, 2023

You need to call c.Use(id) or c.UsePort(port) before you can call that method if your default server isn't valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants