Added support for setting channel permission overrides, closes #20

This commit is contained in:
Bruce Marriner 2015-12-29 10:24:19 -06:00
parent bb4f63775e
commit 57a5245657
2 changed files with 25 additions and 0 deletions

View file

@ -69,6 +69,7 @@ var (
CHANNEL = func(cID string) string { return CHANNELS + cID } CHANNEL = func(cID string) string { return CHANNELS + cID }
CHANNEL_PERMISSIONS = func(cID string) string { return CHANNELS + cID + "/permissions" } 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_INVITES = func(cID string) string { return CHANNELS + cID + "/invites" }
CHANNEL_TYPING = func(cID string) string { return CHANNELS + cID + "/typing" } CHANNEL_TYPING = func(cID string) string { return CHANNELS + cID + "/typing" }
CHANNEL_MESSAGES = func(cID string) string { return CHANNELS + cID + "/messages" } CHANNEL_MESSAGES = func(cID string) string { return CHANNELS + cID + "/messages" }

View file

@ -560,6 +560,30 @@ func (s *Session) ChannelInviteCreate(channelID string, i Invite) (st Invite, er
return 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 // Functions specific to Discord Invites
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------