slapid and player now links when registering
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user