Skip to content

Commit

Permalink
Add time delay for "too many requests" error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vennekilde committed Apr 1, 2024
1 parent 014a9c9 commit b86e4be
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/guild/guilds.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package guild
import (
"fmt"
"regexp"
"time"

"github.com/MrGunflame/gw2api"
"github.com/bwmarrin/discordgo"
Expand Down Expand Up @@ -183,6 +184,9 @@ func (g *Guilds) GetGuildInfo(guildIds *[]string) []*gw2api.Guild {
gw2ApiGuild, err := g.gw2API.Guild(id, false)
if err != nil {
zap.L().Warn("unable to fetch guild", zap.String("guild id", id), zap.Error(err))
if err.Error() == "too many requests" {
time.Sleep(5 * time.Second)
}
continue
}
g.cache[id] = &gw2ApiGuild
Expand Down

0 comments on commit b86e4be

Please sign in to comment.