Fix rate limit
This commit is contained in:
parent
ef1d87a311
commit
a4055c5fd9
|
@ -69,19 +69,27 @@ proc waitForRateLimits*(objectID: snowflake, bucketType: RateLimitBucketType) =
|
||||||
else:
|
else:
|
||||||
case bucketType:
|
case bucketType:
|
||||||
of RateLimitBucketType.channel:
|
of RateLimitBucketType.channel:
|
||||||
|
if (channelRatelimitBucket.hasKey(objectID)):
|
||||||
|
rlmt = channelRatelimitBucket[objectID]
|
||||||
|
else:
|
||||||
|
channelRatelimitBucket.add(objectID, newRateLimit())
|
||||||
rlmt = channelRatelimitBucket[objectID]
|
rlmt = channelRatelimitBucket[objectID]
|
||||||
discard
|
|
||||||
of RateLimitBucketType.guild:
|
of RateLimitBucketType.guild:
|
||||||
|
if (guildRatelimitBucket.hasKey(objectID)):
|
||||||
|
rlmt = guildRatelimitBucket[objectID]
|
||||||
|
else:
|
||||||
|
guildRatelimitBucket.add(objectID, newRateLimit())
|
||||||
rlmt = guildRatelimitBucket[objectID]
|
rlmt = guildRatelimitBucket[objectID]
|
||||||
discard
|
|
||||||
of RateLimitBucketType.webhook:
|
of RateLimitBucketType.webhook:
|
||||||
|
if (webhookRatelimitBucket.hasKey(objectID)):
|
||||||
|
rlmt = webhookRatelimitBucket[objectID]
|
||||||
|
else:
|
||||||
|
webhookRatelimitBucket.add(objectID, newRateLimit())
|
||||||
rlmt = webhookRatelimitBucket[objectID]
|
rlmt = webhookRatelimitBucket[objectID]
|
||||||
discard
|
|
||||||
of RateLimitBucketType.global:
|
of RateLimitBucketType.global:
|
||||||
rlmt = globalRateLimit
|
rlmt = globalRateLimit
|
||||||
discard
|
|
||||||
|
|
||||||
if (rlmt.remainingLimit == 0):
|
if (rlmt != nil and rlmt.remainingLimit == 0):
|
||||||
let millisecondTime: float = rlmt.ratelimitReset * 1000 - epochTime() * 1000
|
let millisecondTime: float = rlmt.ratelimitReset * 1000 - epochTime() * 1000
|
||||||
|
|
||||||
if (millisecondTime > 0):
|
if (millisecondTime > 0):
|
||||||
|
|
Reference in New Issue