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.
|
mute*: bool ## Whether the user is muted in voice channels.
|
||||||
|
|
||||||
|
|
||||||
proc newGuildMember*(json: JsonNode): GuildMember =
|
proc newGuildMember*(memberJson: JsonNode): GuildMember {.inline.} =
|
||||||
var member = GuildMember(
|
var member = GuildMember(
|
||||||
nick: json["nick"].getStr(),
|
nick: memberJson{"nick"}.getStr(),
|
||||||
#roles: seq[Role]
|
#roles: seq[Role]
|
||||||
joinedAt: json["joined_at"].getStr(),
|
joinedAt: memberJson["joined_at"].getStr(),
|
||||||
premiumSince: json["premium_since"].getStr(),
|
premiumSince: memberJson{"premium_since"}.getStr(),
|
||||||
deaf: json["deaf"].getBool(),
|
deaf: memberJson["deaf"].getBool(),
|
||||||
mute: json["mute"].getBool()
|
mute: memberJson["mute"].getBool()
|
||||||
)
|
)
|
||||||
|
|
||||||
if (json.contains("user")):
|
if (memberJson.contains("user")):
|
||||||
member.user = newUser(json["user"])
|
member.user = newUser(memberJson["user"])
|
||||||
|
|
||||||
return member
|
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.
|
premiumType*: NitroSubscription ## The type of Nitro subscription on a user's account.
|
||||||
publicFlags*: int ## The public flags 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(
|
return User(
|
||||||
id: getIDFromJson(json["id"].getStr()),
|
id: getIDFromJson(user["id"].getStr()),
|
||||||
username: json["username"].getStr(),
|
username: user["username"].getStr(),
|
||||||
discriminator: cushort(json["discriminator"].getInt()),
|
discriminator: cushort(user["discriminator"].getInt()),
|
||||||
avatar: json["avatar"].getStr(),
|
avatar: user["avatar"].getStr(),
|
||||||
bot: json{"bot"}.getBool(),
|
bot: user{"bot"}.getBool(),
|
||||||
system: json{"system"}.getBool(),
|
system: user{"system"}.getBool(),
|
||||||
mfaEnabled: json{"mfa_enabled"}.getBool(),
|
mfaEnabled: user{"mfa_enabled"}.getBool(),
|
||||||
locale: json{"locale"}.getStr(),
|
locale: user{"locale"}.getStr(),
|
||||||
verified: json["verified"].getBool(),
|
verified: user{"verified"}.getBool(),
|
||||||
email: json["email"].getStr(),
|
email: user{"email"}.getStr(),
|
||||||
flags: json["flags"].getInt(),
|
flags: user{"flags"}.getInt(),
|
||||||
premiumType: NitroSubscription(json["premium_type"].getInt()),
|
premiumType: NitroSubscription(user{"premium_type"}.getInt()),
|
||||||
publicFlags: json["public_flags"].getInt()
|
publicFlags: user{"public_flags"}.getInt()
|
||||||
)
|
)
|
Reference in New Issue