From 6781ee5eea6c5474486401234ee00753d1119283 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Sun, 31 May 2020 01:14:21 -0500 Subject: [PATCH] Dont shadow json module. --- src/member.nim | 18 +++++++++--------- src/user.nim | 28 ++++++++++++++-------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/member.nim b/src/member.nim index 33346b5..a30686c 100644 --- a/src/member.nim +++ b/src/member.nim @@ -11,18 +11,18 @@ type GuildMember* = object of DiscordObject mute*: bool ## Whether the user is muted in voice channels. -proc newGuildMember*(json: JsonNode): GuildMember = +proc newGuildMember*(memberJson: JsonNode): GuildMember {.inline.} = var member = GuildMember( - nick: json["nick"].getStr(), + nick: memberJson{"nick"}.getStr(), #roles: seq[Role] - joinedAt: json["joined_at"].getStr(), - premiumSince: json["premium_since"].getStr(), - deaf: json["deaf"].getBool(), - mute: json["mute"].getBool() + joinedAt: memberJson["joined_at"].getStr(), + premiumSince: memberJson{"premium_since"}.getStr(), + deaf: memberJson["deaf"].getBool(), + mute: memberJson["mute"].getBool() ) - - if (json.contains("user")): - member.user = newUser(json["user"]) + + if (memberJson.contains("user")): + member.user = newUser(memberJson["user"]) return member \ No newline at end of file diff --git a/src/user.nim b/src/user.nim index bf1eedc..a70b040 100644 --- a/src/user.nim +++ b/src/user.nim @@ -21,19 +21,19 @@ type premiumType*: NitroSubscription ## The type of Nitro subscription on a user's account. publicFlags*: int ## The public flags on a user's account. -proc newUser*(json: json.JsonNode): User = +proc newUser*(user: JsonNode): User {.inline.} = return User( - id: getIDFromJson(json["id"].getStr()), - username: json["username"].getStr(), - discriminator: cushort(json["discriminator"].getInt()), - avatar: json["avatar"].getStr(), - bot: json{"bot"}.getBool(), - system: json{"system"}.getBool(), - mfaEnabled: json{"mfa_enabled"}.getBool(), - locale: json{"locale"}.getStr(), - verified: json["verified"].getBool(), - email: json["email"].getStr(), - flags: json["flags"].getInt(), - premiumType: NitroSubscription(json["premium_type"].getInt()), - publicFlags: json["public_flags"].getInt() + id: getIDFromJson(user["id"].getStr()), + username: user["username"].getStr(), + discriminator: cushort(user["discriminator"].getInt()), + avatar: user["avatar"].getStr(), + bot: user{"bot"}.getBool(), + system: user{"system"}.getBool(), + mfaEnabled: user{"mfa_enabled"}.getBool(), + locale: user{"locale"}.getStr(), + verified: user{"verified"}.getBool(), + email: user{"email"}.getStr(), + flags: user{"flags"}.getInt(), + premiumType: NitroSubscription(user{"premium_type"}.getInt()), + publicFlags: user{"public_flags"}.getInt() ) \ No newline at end of file