Skip to content

Commit

Permalink
fix: getGameHighScores returns an array of high scores instead of a s…
Browse files Browse the repository at this point in the history
…ingle object
  • Loading branch information
drifteri committed Jun 18, 2024
1 parent de43730 commit b1f856a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,8 @@ func (b *Bot) SetGameScore(ctx context.Context, params *SetGameScoreParams) (*mo
}

// GetGameHighScores https://core.telegram.org/bots/api#getgamehighscores
func (b *Bot) GetGameHighScores(ctx context.Context, params *GetGameHighScoresParams) (*models.GameHighScore, error) {
result := &models.GameHighScore{}
err := b.rawRequest(ctx, "getGameHighScores", params, result)
func (b *Bot) GetGameHighScores(ctx context.Context, params *GetGameHighScoresParams) ([]*models.GameHighScore, error) {
var result []*models.GameHighScore
err := b.rawRequest(ctx, "getGameHighScores", params, &result)
return result, err
}
4 changes: 2 additions & 2 deletions methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1377,15 +1377,15 @@ func TestBot_Methods(t *testing.T) {
})

t.Run("GetGameHighScores", func(t *testing.T) {
c := &httpClient{t: t, resp: `{"score":42}`, reqFields: map[string]string{
c := &httpClient{t: t, resp: `[{"score":42}]`, reqFields: map[string]string{
"chat_id": "123",
}}
b := &Bot{client: c}
resp, err := b.GetGameHighScores(context.Background(), &GetGameHighScoresParams{
ChatID: 123,
})
assertNoErr(t, err)
assertEqualInt(t, 42, resp.Score)
assertEqualInt(t, 42, resp[0].Score)
})

}

0 comments on commit b1f856a

Please sign in to comment.