2020-05-31 04:44:37 +00:00
|
|
|
import json, discordobject, nimcordutils
|
2020-05-30 19:13:58 +00:00
|
|
|
|
2020-05-31 04:44:37 +00:00
|
|
|
type
|
|
|
|
NitroSubscription* = enum
|
|
|
|
none = 0,
|
|
|
|
nitroClassic = 1,
|
|
|
|
nitro = 2
|
|
|
|
|
2020-06-18 20:58:10 +00:00
|
|
|
User* = ref object of DiscordObject
|
2020-05-31 04:44:37 +00:00
|
|
|
## This type is a discord user.
|
|
|
|
username*: string ## The user's username, not unique across the platform.
|
|
|
|
discriminator*: cushort ## The user's 4-digit discord-tag.
|
|
|
|
avatar*: string ## The user's avatar hash.
|
|
|
|
bot*: bool ## Whether the user belongs to an OAuth2 application.
|
|
|
|
system*: bool ## Whether the user is an Official Discord System user (part of the urgent message system).
|
|
|
|
mfaEnabled*: bool ## Whether the user has two factor enabled on their account .
|
|
|
|
locale*: string ## The user's chosen language option .
|
|
|
|
verified*: bool ## Whether the email on this account has been verified.
|
|
|
|
email*: string ## The user's email.
|
|
|
|
flags*: int ## The flags 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.
|
|
|
|
|
2020-05-31 06:14:21 +00:00
|
|
|
proc newUser*(user: JsonNode): User {.inline.} =
|
2020-05-31 04:44:37 +00:00
|
|
|
return User(
|
2020-05-31 06:14:21 +00:00
|
|
|
id: getIDFromJson(user["id"].getStr()),
|
|
|
|
username: user["username"].getStr(),
|
2020-06-18 03:16:21 +00:00
|
|
|
discriminator: cushort(parseIntEasy(user["discriminator"].getStr())),
|
2020-05-31 06:14:21 +00:00
|
|
|
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()
|
2020-05-31 04:44:37 +00:00
|
|
|
)
|