This repository has been archived on 2023-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
nimcord/src/member.nim

28 lines
1.0 KiB
Nim
Raw Normal View History

import discordobject, user, json
type GuildMember* = object of DiscordObject
## This type is a guild member.
user*: User ## The user this guild member represents.
nick*: string ## This users guild nickname.
#roles*: seq[Role] ## Array of roles.
joinedAt*: string ## When the user joined the guild.
premiumSince*: string ## When the user started boosting the guild.
deaf*: bool ## Whether the user is deafened in voice channels.
mute*: bool ## Whether the user is muted in voice channels.
2020-05-31 06:14:21 +00:00
proc newGuildMember*(memberJson: JsonNode): GuildMember {.inline.} =
var member = GuildMember(
2020-05-31 06:14:21 +00:00
nick: memberJson{"nick"}.getStr(),
#roles: seq[Role]
2020-05-31 06:14:21 +00:00
joinedAt: memberJson["joined_at"].getStr(),
premiumSince: memberJson{"premium_since"}.getStr(),
deaf: memberJson["deaf"].getBool(),
mute: memberJson["mute"].getBool()
)
2020-05-31 06:14:21 +00:00
if (memberJson.contains("user")):
member.user = newUser(memberJson["user"])
return member