diff --git a/endpoints.go b/endpoints.go index 5184706..1e5d370 100644 --- a/endpoints.go +++ b/endpoints.go @@ -69,6 +69,7 @@ var ( CHANNEL = func(cID string) string { return CHANNELS + cID } CHANNEL_PERMISSIONS = func(cID string) string { return CHANNELS + cID + "/permissions" } + CHANNEL_PERMISSION = func(cID, tID string) string { return CHANNELS + cID + "/permissions/" + tID } CHANNEL_INVITES = func(cID string) string { return CHANNELS + cID + "/invites" } CHANNEL_TYPING = func(cID string) string { return CHANNELS + cID + "/typing" } CHANNEL_MESSAGES = func(cID string) string { return CHANNELS + cID + "/messages" } diff --git a/restapi.go b/restapi.go index 8403e92..5aca49a 100644 --- a/restapi.go +++ b/restapi.go @@ -560,6 +560,30 @@ func (s *Session) ChannelInviteCreate(channelID string, i Invite) (st Invite, er return } +// ChannelPermissionSet creates a Permission Override for the given channel. +// NOTE: This func name may changed. Using Set instead of Create because +// you can both create a new override or update an override with this function. +func (s *Session) ChannelPermissionSet(channelID, targetID, targetType string, allow, deny int) (err error) { + + data := struct { + ID string `json:"id"` + Type string `json:"type"` + Allow int `json:"allow"` + Deny int `json:"deny"` + }{targetID, targetType, allow, deny} + + _, err = s.Request("PUT", CHANNEL_PERMISSION(channelID, targetID), data) + return +} + +// ChannelPermissionDelete deletes a specific permission override for the given channel. +// NOTE: Name of this func may change. +func (s *Session) ChannelPermissionDelete(channelID, targetID string) (err error) { + + _, err = s.Request("DELETE", CHANNEL_PERMISSION(channelID, targetID), nil) + return +} + // ------------------------------------------------------------------------------------------------ // Functions specific to Discord Invites // ------------------------------------------------------------------------------------------------