Add new permissions constructor and create Role type
This commit is contained in:
parent
153b5ee764
commit
28649645e3
|
@ -44,6 +44,10 @@ type
|
|||
denyPerms*: uint
|
||||
permissionType*: PermissionType
|
||||
|
||||
proc newPermissions*(id: snowflake, `type`: PermissionType, byteSet: uint): Permissions =
|
||||
## Create a new `Permissions` using an id, type, and byte set.
|
||||
result = Permissions(roleUserID: id, permissionType: `type`, allowPerms: byteSet)
|
||||
|
||||
proc newPermissions*(json: JsonNode): Permissions =
|
||||
## Parses a `Permissions` from json.
|
||||
result = Permissions(
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
import json, nimcordutils, discordobject, permission
|
||||
|
||||
type Role* = ref object of DiscordObject
|
||||
name*: string
|
||||
color*: uint
|
||||
hoist*: bool
|
||||
position*: uint
|
||||
permissions*: Permissions
|
||||
managed*: bool
|
||||
mentionable*: bool
|
||||
|
||||
proc newRole*(json: JsonNode): Role =
|
||||
result = Role(
|
||||
id: getIDFromJson(json["id"].getStr()),
|
||||
name: json["name"].getStr(),
|
||||
color: uint(json["color"].getInt()),
|
||||
hoist: json["hoist"].getBool(),
|
||||
position: uint(json["position"].getInt()),
|
||||
permissions: newPermissions(json["permissions"]),
|
||||
managed: json["managed"].getBool(),
|
||||
mentionable: json["mentionable"].getBool()
|
||||
)
|
Reference in New Issue