Fix presence.
This commit is contained in:
parent
cda772f4fa
commit
4c71b7f0f9
|
@ -79,12 +79,11 @@ proc newActivity*(json: JsonNode, guildID: snowflake): Activity =
|
||||||
)
|
)
|
||||||
|
|
||||||
if (json.contains("timestamps")):
|
if (json.contains("timestamps")):
|
||||||
for timestamp in json["timestamps"]:
|
var time = ActivityTimestamp()
|
||||||
var time: ActivityTimestamp
|
if (json["timestamps"].contains("start")):
|
||||||
if (timestamp.contains("start")):
|
time.startTime = uint(json["timestamps"]{"start"}.getInt())
|
||||||
time.startTime = uint(timestamp["start"].getInt())
|
if (json["timestamps"].contains("end")):
|
||||||
if (timestamp.contains("end")):
|
time.endTime = uint(json["timestamps"]{"end"}.getInt())
|
||||||
time.endTime = uint(timestamp["end"].getInt())
|
|
||||||
|
|
||||||
act.timestamps.add(time)
|
act.timestamps.add(time)
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ proc newActivity*(json: JsonNode, guildID: snowflake): Activity =
|
||||||
act.emoji = newEmoji(json["emoji"], guildID)
|
act.emoji = newEmoji(json["emoji"], guildID)
|
||||||
|
|
||||||
if (json.contains("party")):
|
if (json.contains("party")):
|
||||||
var party: ActivityParty
|
var party = ActivityParty()
|
||||||
if (json["party"].contains("id")):
|
if (json["party"].contains("id")):
|
||||||
party.id = json["party"]["id"].getStr()
|
party.id = json["party"]["id"].getStr()
|
||||||
if (json["party"].contains("size")):
|
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())
|
party.maxSize = uint(json["party"]["size"].elems[1].getInt())
|
||||||
|
|
||||||
if (json.contains("assets")):
|
if (json.contains("assets")):
|
||||||
var assets: ActivityAssets
|
var assets = ActivityAssets()
|
||||||
if (json["assets"].contains("large_image")):
|
if (json["assets"].contains("large_image")):
|
||||||
assets.largeImg = json["assets"]["large_image"].getStr()
|
assets.largeImg = json["assets"]["large_image"].getStr()
|
||||||
if (json["assets"].contains("large_text")):
|
if (json["assets"].contains("large_text")):
|
||||||
|
@ -111,7 +110,7 @@ proc newActivity*(json: JsonNode, guildID: snowflake): Activity =
|
||||||
assets.smallText = json["assets"]["small_text"].getStr()
|
assets.smallText = json["assets"]["small_text"].getStr()
|
||||||
|
|
||||||
if (json.contains("secrets")):
|
if (json.contains("secrets")):
|
||||||
var secrets: ActivitySecrets
|
var secrets = ActivitySecrets()
|
||||||
if (json["secrets"].contains("join")):
|
if (json["secrets"].contains("join")):
|
||||||
secrets.join = json["secrets"]["join"].getStr()
|
secrets.join = json["secrets"]["join"].getStr()
|
||||||
if (json["secrets"].contains("spectate")):
|
if (json["secrets"].contains("spectate")):
|
||||||
|
@ -126,7 +125,8 @@ proc newPresence*(json: JsonNode): Presence =
|
||||||
)
|
)
|
||||||
|
|
||||||
if (json.contains("game") and json["game"].getFields().len > 0):
|
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"):
|
if json.contains("activities"):
|
||||||
for activity in json["activities"]:
|
for activity in json["activities"]:
|
||||||
|
|
Reference in New Issue