~xenrox/twitch-bot

c6c5d34f9d30ff7c42fd1bfc56b35e4e693ce96c — Thorben Günther 3 months ago 1dadc7a master
faceit: Print CS2 elo
1 files changed, 5 insertions(+), 5 deletions(-)

M faceit.go
M faceit.go => faceit.go +5 -5
@@ 24,9 24,9 @@ type faceitClient struct {
type playerInfo struct {
	PlayerID string `json:"player_id"`
	Games    struct {
		CSGO struct {
		CS2 struct {
			Elo int `json:"faceit_elo"`
		} `json:"csgo"`
		} `json:"cs2"`
	} `json:"games"`
}



@@ 59,7 59,7 @@ func (b *bot) getElo(channel string, parsed []string) (int, error) {
	var url string

	if len(parsed) > 1 {
		url = fmt.Sprintf("https://open.faceit.com/data/v4/players?nickname=%s&game=csgo", parsed[1])
		url = fmt.Sprintf("https://open.faceit.com/data/v4/players?nickname=%s&game=cs2", parsed[1])
	} else {
		playerID, err := b.getPlayerID(channel)
		if err != nil {


@@ 75,7 75,7 @@ func (b *bot) getElo(channel string, parsed []string) (int, error) {
		return 0, err
	}

	return player.Games.CSGO.Elo, nil
	return player.Games.CS2.Elo, nil
}

func (b *bot) getPlayerID(channel string) (string, error) {


@@ 95,7 95,7 @@ func (b *bot) getPlayerID(channel string) (string, error) {

func (b *bot) setFaceitID(faceitAPIKey string, channel string, name string) error {
	client := newFaceitClient(faceitAPIKey)
	url := fmt.Sprintf("https://open.faceit.com/data/v4/players?nickname=%s&game=csgo", name)
	url := fmt.Sprintf("https://open.faceit.com/data/v4/players?nickname=%s&game=cs2", name)

	player, err := client.getPlayerInfo(url)
	if err != nil {