Only add shard in identify if shard count is more than 1

This commit is contained in:
SeanOMik 2020-06-23 23:06:56 -05:00
parent 8a9436f831
commit a061c825ef
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
2 changed files with 6 additions and 4 deletions

View File

@ -99,4 +99,4 @@ registerEventListener(EventType.evtMessageCreate, proc(bEvt: BaseEvent) =
discard channel.sendMessage("", false, embed, @[file]) discard channel.sendMessage("", false, embed, @[file])
) )
waitFor bot.startConnection(2) waitFor bot.startConnection()

View File

@ -41,11 +41,10 @@ proc handleHeartbeat(shard: Shard) {.async.} =
await sleepAsync(shard.heartbeatInterval) await sleepAsync(shard.heartbeatInterval)
proc getIdentifyPacket(shard: Shard): JsonNode = proc getIdentifyPacket(shard: Shard): JsonNode =
return %* { result = %* {
"op": ord(DiscordOpCode.opIdentify), "op": ord(DiscordOpCode.opIdentify),
"d": { "d": {
"token": shard.client.token, "token": shard.client.token,
"shard": [shard.id, shard.client.shardCount],
"properties": { "properties": {
"$os": system.hostOS, "$os": system.hostOS,
"$browser": "NimCord", "$browser": "NimCord",
@ -54,6 +53,9 @@ proc getIdentifyPacket(shard: Shard): JsonNode =
} }
} }
if (shard.client.shardCount != -1):
result.add("shard", %*[shard.id, shard.client.shardCount])
# For some reason this shows as an error in VSCode, but it compiles fine. # For some reason this shows as an error in VSCode, but it compiles fine.
#proc startConnection*(client: DiscordClient, shardCount: int = 1) {.async.} #proc startConnection*(client: DiscordClient, shardCount: int = 1) {.async.}