diff --git a/cmd/bot/user.go b/cmd/bot/user.go index cca90f4..1e6cfc9 100644 --- a/cmd/bot/user.go +++ b/cmd/bot/user.go @@ -103,12 +103,14 @@ func (app *Application) SetUserLocation(message twitch.PrivateMessage) { // handlers as the `location` part of the command. location := message.Message[snipLength:len(message.Message)] login := message.User.Name + twitchId := message.User.ID app.Logger.Infow("SetUserLocation", "location", location, "login", login, + "twitchId", message.User.ID, ) - err := app.Models.Users.SetLocation(login, location) + err := app.Models.Users.SetLocation(twitchId, location) if err != nil { common.Send(message.Channel, fmt.Sprintf("Something went wrong FeelsBadMan %s", ErrRecordNotFound), app.TwitchClient) app.Logger.Error(err) diff --git a/internal/data/users.go b/internal/data/users.go index 746ba9d..01ed131 100644 --- a/internal/data/users.go +++ b/internal/data/users.go @@ -53,13 +53,13 @@ func (u UserModel) Insert(login, twitchId string) error { // SetLocation searches the database for a record with the provided login value // and if that exists sets the location to the supplied -func (u UserModel) SetLocation(login, location string) error { +func (u UserModel) SetLocation(twitchId, location string) error { query := ` UPDATE users SET location = $2 - WHERE login = $1` + WHERE twitchId = $1` - result, err := u.DB.Exec(query, login, location) + result, err := u.DB.Exec(query, twitchId, location) if err != nil { return err }