From c8810604acd27a80df0c0dcd9636818da6316ef8 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Thu, 18 Jun 2020 18:31:57 -0500 Subject: [PATCH] Add Role, Emoji, and Permissions to the Guild type. --- src/guild.nim | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/guild.nim b/src/guild.nim index bc06eca..550496d 100644 --- a/src/guild.nim +++ b/src/guild.nim @@ -1,4 +1,4 @@ -import json, discordobject, channel, member, options, nimcordutils +import json, discordobject, channel, member, options, nimcordutils, emoji, role, permission type ChannelType* = enum @@ -43,16 +43,15 @@ type discoverySplash*: string owner*: bool ownerID: snowflake - #TODO: Convert this to a Permissions type - permissions*: int + permissions*: Permissions region*: string afkChannelID*: snowflake afkTimeout*: int verificationLevel*: VerificationLevel defaultMessageNotifications*: MessageNotificationsLevel explicitContentFilter*: ExplicitContentFilterLevel - #roles*: seq[Role] - #emojis*: seq[Emoji] + roles*: seq[Role] + emojis*: seq[Emoji] features*: seq[string] mfaLevel*: MFALevel applicationID*: snowflake @@ -97,8 +96,6 @@ proc newGuild*(json: JsonNode): Guild {.inline.} = verificationLevel: VerificationLevel(json["verification_level"].getInt()), defaultMessageNotifications: MessageNotificationsLevel(json["default_message_notifications"].getInt()), explicitContentFilter: ExplicitContentFilterLevel(json["explicit_content_filter"].getInt()), - #roles - #emojis #features mfaLevel: MFALevel(json["mfa_level"].getInt()), applicationID: getIDFromJson(json["application_id"].getStr()), @@ -116,9 +113,13 @@ proc newGuild*(json: JsonNode): Guild {.inline.} = # Parse all non guaranteed fields if (json.contains("owner")): g.owner = json["owner"].getBool() - if (json.contains("owner_id")): - g.ownerID = getIDFromJson(json["owner_id"].getStr()) - #TODO: permissions + if (json.contains("permissions")): + g.permissions = newPermissions(json["permissions"]) + for role in json["roles"]: + g.roles.add(newRole(role)) + for emoji in json["emojis"]: + g.emojis.add(newEmoji(emoji)) + #TODO features if (json.contains("widget_enabled")): g.widgetEnabled = json["widget_enabled"].getBool() if (json.contains("widget_channel_id")):