fix owner id

This commit is contained in:
Dot-Rar 2020-04-17 13:48:59 +01:00
parent 820a161a12
commit 0c79deb2ad

View File

@ -84,13 +84,22 @@ func CallbackHandler(ctx *gin.Context) {
// Cache guilds because Discord takes like 2 whole seconds to return then // Cache guilds because Discord takes like 2 whole seconds to return then
go func() { go func() {
var guilds []guild.Guild var guilds []*guild.Guild
err, _ = userEndpoint.CurrentUserGuilds.Request(store, nil, nil, &guilds) err, _ = userEndpoint.CurrentUserGuilds.Request(store, nil, nil, &guilds)
if err != nil { if err != nil {
log.Error(err.Error()) log.Error(err.Error())
return return
} }
// endpoint's partial guild doesn't include ownerid
// we only user cached guilds on the index page, so it doesn't matter if we don't have have the real owner id
// if the user isn't the owner, as we pull from the cache on other endpoints
for _, guild := range guilds {
if guild.Owner {
guild.OwnerId = currentUser.Id
}
}
marshalled, err := json.Marshal(guilds) marshalled, err := json.Marshal(guilds)
if err != nil { if err != nil {
log.Error(err.Error()) log.Error(err.Error())