From a061c825ef74ee97f8300db4f51b0ee19d228347 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Tue, 23 Jun 2020 23:06:56 -0500 Subject: [PATCH] Only add shard in identify if shard count is more than 1 --- examples/basic.nim | 2 +- src/nimcord/client.nim | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/basic.nim b/examples/basic.nim index 238a58a..21e2545 100644 --- a/examples/basic.nim +++ b/examples/basic.nim @@ -99,4 +99,4 @@ registerEventListener(EventType.evtMessageCreate, proc(bEvt: BaseEvent) = discard channel.sendMessage("", false, embed, @[file]) ) -waitFor bot.startConnection(2) \ No newline at end of file +waitFor bot.startConnection() \ No newline at end of file diff --git a/src/nimcord/client.nim b/src/nimcord/client.nim index d037e9c..6b9f812 100644 --- a/src/nimcord/client.nim +++ b/src/nimcord/client.nim @@ -41,12 +41,11 @@ proc handleHeartbeat(shard: Shard) {.async.} = await sleepAsync(shard.heartbeatInterval) proc getIdentifyPacket(shard: Shard): JsonNode = - return %* { + result = %* { "op": ord(DiscordOpCode.opIdentify), "d": { "token": shard.client.token, - "shard": [shard.id, shard.client.shardCount], - "properties": { + "properties": { "$os": system.hostOS, "$browser": "NimCord", "$device": "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. #proc startConnection*(client: DiscordClient, shardCount: int = 1) {.async.}