Dont shadow json module.
This commit is contained in:
parent
512239b986
commit
6781ee5eea
|
@ -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
|
||||
|
28
src/user.nim
28
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()
|
||||
)
|
Reference in New Issue