slapid and player now links when registering

This commit is contained in:
2026-02-17 18:33:22 +11:00
parent 35eb2e695a
commit c16db1bf60
11 changed files with 137 additions and 28 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"
"github.com/pkg/errors"
)
@@ -30,7 +31,9 @@ type idresp struct {
ID uint32 `json:"id"`
}
// GetSlapID returns the slapshot ID of the steam user
var ErrNoSlapID error = errors.New("slapID not found")
// GetSlapID returns the slapshot ID of the steam user.
func (c *SlapAPI) GetSlapID(
ctx context.Context,
steamid string,
@@ -38,7 +41,10 @@ func (c *SlapAPI) GetSlapID(
endpoint := getEndpointSteamID(steamid)
data, err := c.request(ctx, endpoint)
if err != nil {
return 0, errors.Wrap(err, "slapapiReq")
if strings.Contains(err.Error(), "404") {
return 0, ErrNoSlapID
}
return 0, errors.Wrap(err, "c.request")
}
resp := idresp{}
err = json.Unmarshal(data, &resp)