Add Permissions to the channels type.

This commit is contained in:
SeanOMik 2020-06-18 18:05:28 -05:00
parent 0af96d238d
commit 28fd1c443a
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
1 changed files with 10 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import json, discordobject, user, options, nimcordutils, message, httpcore, asyncdispatch, asyncfutures, strutils import json, discordobject, user, options, nimcordutils, message, httpcore, asyncdispatch, asyncfutures, permission
type type
ChannelType* = enum ChannelType* = enum
@ -16,7 +16,7 @@ type
`type`*: ChannelType ## The type of channel. `type`*: ChannelType ## The type of channel.
guildID*: snowflake ## The id of the guild. guildID*: snowflake ## The id of the guild.
position*: int ## Sorting position of the channel. position*: int ## Sorting position of the channel.
#permissionOverwrites*: seq[Permissions] ## Explicit permission overwrites for members and roles. permissionOverwrites*: seq[Permissions] ## Explicit permission overwrites for members and roles.
name*: string ## The name of the channel (2-100 characters). name*: string ## The name of the channel (2-100 characters).
topic*: string ## The channel topic (0-1024 characters). topic*: string ## The channel topic (0-1024 characters).
nsfw*: bool ## Whether the channel is nsfw. nsfw*: bool ## Whether the channel is nsfw.
@ -41,7 +41,7 @@ type
rateLimitPerUser*: Option[int] rateLimitPerUser*: Option[int]
bitrate*: Option[int] bitrate*: Option[int]
userLimit*: Option[int] userLimit*: Option[int]
#permissionOverwrites*: seq[Permissions] ## Explicit permission overwrites for members and roles. permissionOverwrites*: Option[seq[Permissions]] ## Explicit permission overwrites for members and roles.
parentID*: Option[snowflake] parentID*: Option[snowflake]
Invite* = object Invite* = object
@ -72,7 +72,8 @@ proc newChannel*(channel: JsonNode): Channel {.inline.} =
if (channel.contains("position")): if (channel.contains("position")):
chan.position = channel["position"].getInt() chan.position = channel["position"].getInt()
if (channel.contains("permission_overwrites")): if (channel.contains("permission_overwrites")):
echo "permission_overwrites" for perm in channel["permission_overwrites"]:
chan.permissionOverwrites.add(newPermissions(perm))
if (channel.contains("name")): if (channel.contains("name")):
chan.name = channel["name"].getStr() chan.name = channel["name"].getStr()
if (channel.contains("topic")): if (channel.contains("topic")):
@ -173,8 +174,11 @@ proc modifyChannel*(channel: Channel, modify: ChannelModify): Future[Channel] {.
if (modify.userLimit.isSome): if (modify.userLimit.isSome):
modifyPayload.add("user_limit", %modify.userLimit.get()) modifyPayload.add("user_limit", %modify.userLimit.get())
#[ if (modify.name.isSome): if (modify.permissionOverwrites.isSome):
modifyPayload.add("permission_overwrites", %modify.parentID.get()0 ]# var permOverwrites = parseJson("[]")
for perm in modify.permissionOverwrites.get():
permOverwrites.add(perm.permissionsToJson())
modifyPayload.add("permission_overwrites", permOverwrites)
if (modify.parentID.isSome): if (modify.parentID.isSome):
modifyPayload.add("parent_id", %modify.parentID.get()) modifyPayload.add("parent_id", %modify.parentID.get())