func (r *RateLimit) UpdateRegisters(key string, resp *http.Response, content []byte) {
	// update time difference
	if discordTime, err := HeaderToTime(&resp.Header); err == nil {
		r.TimeDiff.Update(time.Now(), discordTime)
	}

	// update bucket
	info, err := ExtractRateLimitInfo(resp, content)
	if err != nil {
		return // TODO: logging
	}

	// select bucket
	// TODO: what if "key" is an endpoint with a global rate limiter only?
	var bucket *Bucket
	if info.Global {
		bucket = r.global
	} else {
		bucket = r.Bucket(key)
	}

	// update
	bucket.mu.Lock()
	bucket.update(info, r.TimeDiff.Now())
	bucket.mu.Unlock()
}
// UpdateRegisters updates the relevant buckets and time desync between the
// client and the Discord servers.
UpdateRegisters updates the relevant buckets and time desync between the
client and the Discord servers.
// UpdateRegisters updates the relevant buckets and time desync between the // client and the Discord servers .
func (r *RateLimit) UpdateRegisters(key string, resp *http.Response, content []byte) {
	if discordTime, err := HeaderToTime(&resp.Header); err == nil {
		r.TimeDiff.Update(time.Now(), discordTime)
	}
	info, err := ExtractRateLimitInfo(resp, content)
	if err != nil {
		return 
	}
	var bucket *Bucket
	if info.Global {
		bucket = r.global
	} else {
		bucket = r.Bucket(key)
	}
	bucket.mu.Lock()
	bucket.update(info, r.TimeDiff.Now())
	bucket.mu.Unlock()
}
func ( r * RateLimit ) UpdateRegisters ( key string , resp * http . Response , content [ ] byte ) { if discordTime , err := HeaderToTime ( & resp . Header ) ; err == nil { r . TimeDiff . Update ( time . Now ( ) , discordTime ) } info , err := ExtractRateLimitInfo ( resp , content ) if err != nil { return } var bucket * Bucket if info . Global { bucket = r . global } else { bucket = r . Bucket ( key ) } bucket . mu . Lock ( ) bucket . update ( info , r . TimeDiff . Now ( ) ) bucket . mu . Unlock ( ) }
UpdateRegisters updates the relevant buckets and time desync between the
client and the Discord servers.
UpdateRegisters updates the relevant buckets and time desync between the client and the Discord servers .
// update time difference // update bucket // TODO: logging // select bucket // TODO: what if "key" is an endpoint with a global rate limiter only? // update