From 4c71b7f0f9d6c357cc46df65d8c11eab6dd034f9 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Mon, 22 Jun 2020 18:06:29 -0500 Subject: [PATCH] Fix presence. --- src/nimcord/presence.nim | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/nimcord/presence.nim b/src/nimcord/presence.nim index 5c3bd6f..5772585 100644 --- a/src/nimcord/presence.nim +++ b/src/nimcord/presence.nim @@ -79,20 +79,19 @@ proc newActivity*(json: JsonNode, guildID: snowflake): Activity = ) if (json.contains("timestamps")): - for timestamp in json["timestamps"]: - var time: ActivityTimestamp - if (timestamp.contains("start")): - time.startTime = uint(timestamp["start"].getInt()) - if (timestamp.contains("end")): - time.endTime = uint(timestamp["end"].getInt()) + var time = ActivityTimestamp() + if (json["timestamps"].contains("start")): + time.startTime = uint(json["timestamps"]{"start"}.getInt()) + if (json["timestamps"].contains("end")): + time.endTime = uint(json["timestamps"]{"end"}.getInt()) - act.timestamps.add(time) + act.timestamps.add(time) if (json.contains("emoji")): act.emoji = newEmoji(json["emoji"], guildID) if (json.contains("party")): - var party: ActivityParty + var party = ActivityParty() if (json["party"].contains("id")): party.id = json["party"]["id"].getStr() if (json["party"].contains("size")): @@ -100,7 +99,7 @@ proc newActivity*(json: JsonNode, guildID: snowflake): Activity = party.maxSize = uint(json["party"]["size"].elems[1].getInt()) if (json.contains("assets")): - var assets: ActivityAssets + var assets = ActivityAssets() if (json["assets"].contains("large_image")): assets.largeImg = json["assets"]["large_image"].getStr() if (json["assets"].contains("large_text")): @@ -111,7 +110,7 @@ proc newActivity*(json: JsonNode, guildID: snowflake): Activity = assets.smallText = json["assets"]["small_text"].getStr() if (json.contains("secrets")): - var secrets: ActivitySecrets + var secrets = ActivitySecrets() if (json["secrets"].contains("join")): secrets.join = json["secrets"]["join"].getStr() if (json["secrets"].contains("spectate")): @@ -126,7 +125,8 @@ proc newPresence*(json: JsonNode): Presence = ) if (json.contains("game") and json["game"].getFields().len > 0): - result.game = newActivity(json["game"], getIDFromJson(json{"guild_id"}.getStr())) + let guildID = if json.contains("guild_id"): getIDFromJson(json["guild_id"].getStr()) else: 0 + result.game = newActivity(json["game"], guildID) if json.contains("activities"): for activity in json["activities"]: