select by username rather than id
This commit is contained in:
parent
1df8b395ce
commit
f7a19636e2
2 changed files with 7 additions and 4 deletions
7
bot.go
7
bot.go
|
@ -174,11 +174,13 @@ func (bot *Bot) newMessageHandler(s *discordgo.Session, m *discordgo.MessageCrea
|
|||
return
|
||||
}
|
||||
|
||||
var mapperId int
|
||||
mapperId, err = strconv.Atoi(parts[1])
|
||||
var mapper User
|
||||
mapperName := strings.Join(parts[1:], " ")
|
||||
mapper, err = bot.api.GetUser(mapperName)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
mapperId := mapper.Id
|
||||
|
||||
err = bot.db.ChannelTrackMapper(m.ChannelID, mapperId, 3)
|
||||
if err != nil {
|
||||
|
@ -191,6 +193,7 @@ func (bot *Bot) newMessageHandler(s *discordgo.Session, m *discordgo.MessageCrea
|
|||
}()
|
||||
|
||||
bot.MessageReactionAdd(m.ChannelID, m.ID, "\xf0\x9f\x91\x8d")
|
||||
bot.ChannelMessageSend(m.ChannelID, fmt.Sprintf("subscribed to %+v", mapper))
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -159,8 +159,8 @@ func (api *Osuapi) BeatmapsetDownload(beatmapSetId int) (path string, err error)
|
|||
return
|
||||
}
|
||||
|
||||
func (api *Osuapi) GetUser(userId int) (user User, err error) {
|
||||
url := fmt.Sprintf("/users/%d", userId)
|
||||
func (api *Osuapi) GetUser(userId string) (user User, err error) {
|
||||
url := fmt.Sprintf("/users/%s", userId)
|
||||
err = api.Request("GET", url, &user)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue