Add ChannelEditComplex (#493)

* Add ChannelEditComplex

* Fixed comment format

* gofmt

* Reverted permissions and fixed ChannelEditComplex

* Reverted Perms

* Delete discordgo - Shortcut.lnk

removed link

* Added ChannelID param to ChannelEditComplex

* gofmt
This commit is contained in:
psheets 2017-12-15 00:59:07 -05:00 committed by Chris Rhodes
parent 0003ae7dd2
commit e024d5f032
2 changed files with 21 additions and 5 deletions

View file

@ -1221,12 +1221,16 @@ func (s *Session) Channel(channelID string) (st *Channel, err error) {
// ChannelEdit edits the given channel // ChannelEdit edits the given channel
// channelID : The ID of a Channel // channelID : The ID of a Channel
// name : The new name to assign the channel. // name : The new name to assign the channel.
func (s *Session) ChannelEdit(channelID, name string) (st *Channel, err error) { func (s *Session) ChannelEdit(channelID, name string) (*Channel, error) {
return s.ChannelEditComplex(channelID, &ChannelEdit{
data := struct { Name: name,
Name string `json:"name"` })
}{name} }
// ChannelEditComplex edits an existing channel, replacing the parameters entirely with ChannelEdit struct
// channelID : The ID of a Channel
// data : The channel struct to send
func (s *Session) ChannelEditComplex(channelID string, data *ChannelEdit) (st *Channel, err error) {
body, err := s.RequestWithBucketID("PATCH", EndpointChannel(channelID), data, EndpointChannel(channelID)) body, err := s.RequestWithBucketID("PATCH", EndpointChannel(channelID), data, EndpointChannel(channelID))
if err != nil { if err != nil {
return return

View file

@ -176,6 +176,18 @@ type Channel struct {
ParentID string `json:"parent_id"` ParentID string `json:"parent_id"`
} }
// A ChannelEdit holds Channel Feild data for a channel edit.
type ChannelEdit struct {
Name string `json:"name,omitempty"`
Topic string `json:"topic,omitempty"`
NSFW bool `json:"nsfw,omitempty"`
Position int `json:"position"`
Bitrate int `json:"bitrate,omitempty"`
UserLimit int `json:"user_limit,omitempty"`
PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
ParentID string `json:"parent_id,omitempty"`
}
// A PermissionOverwrite holds permission overwrite data for a Channel // A PermissionOverwrite holds permission overwrite data for a Channel
type PermissionOverwrite struct { type PermissionOverwrite struct {
ID string `json:"id"` ID string `json:"id"`