From 9d82a047273c18c6b7638a7ca4aefaa89c8fe449 Mon Sep 17 00:00:00 2001 From: ayn2op Date: Sun, 21 Dec 2025 17:21:33 -0500 Subject: [PATCH] refactor(http): set user agent on instance of api.Client instead of package-level global --- cmd/state.go | 3 --- internal/http/client.go | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/state.go b/cmd/state.go index 0e4bd1e..653188c 100644 --- a/cmd/state.go +++ b/cmd/state.go @@ -7,7 +7,6 @@ import ( "github.com/ayn2op/discordo/internal/http" "github.com/ayn2op/discordo/internal/notifications" "github.com/ayn2op/tview" - "github.com/diamondburned/arikawa/v3/api" "github.com/diamondburned/arikawa/v3/gateway" "github.com/diamondburned/arikawa/v3/session" "github.com/diamondburned/arikawa/v3/state" @@ -22,8 +21,6 @@ import ( func openState(token string) error { identifyProps := http.IdentifyProperties() - - api.UserAgent = http.BrowserUserAgent gateway.DefaultIdentity = identifyProps gateway.DefaultPresence = &gateway.UpdatePresenceCommand{ Status: app.cfg.Status, diff --git a/internal/http/client.go b/internal/http/client.go index fcf6d25..c1303c2 100644 --- a/internal/http/client.go +++ b/internal/http/client.go @@ -12,5 +12,7 @@ func NewClient(token string) *api.Client { stdClient := http.DefaultClient stdClient.Transport = NewTransport() httpClient := httputil.NewClientWithDriver(httpdriver.WrapClient(*stdClient)) - return api.NewCustomClient(token, httpClient) + apiClient := api.NewCustomClient(token, httpClient) + apiClient.UserAgent = BrowserUserAgent + return apiClient }