Added GuildChannelCreateComplex

This commit is contained in:
Rens Rikkerink 2018-05-09 14:55:49 +02:00
parent 82c8cf21b2
commit 80ac382641
No known key found for this signature in database
GPG key ID: 204C7F94FBEC05FC

View file

@ -910,17 +910,22 @@ func (s *Session) GuildChannels(guildID string) (st []*Channel, err error) {
return
}
// GuildChannelCreate creates a new channel in the given guild
// guildID : The ID of a Guild.
// name : Name of the channel (2-100 chars length)
// ctype : Type of the channel
func (s *Session) GuildChannelCreate(guildID, name string, ctype ChannelType) (st *Channel, err error) {
data := struct {
Name string `json:"name"`
Type ChannelType `json:"type"`
}{name, ctype}
// GuildChannelCreateData is provided to GuildChannelCreateComplex
type GuildChannelCreateData struct {
Name string `json:"name"`
Type ChannelType `json:"type"`
Topic string `json:"topic,omitempty"`
Bitrate int `json:"bitrate,omitempty"`
UserLimit int `json:"user_limit,omitempty"`
PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
ParentID string `json:"parent_id,omitempty"`
NSFW bool `json:"nsfw,omitempty"`
}
// GuildChannelCreateComplex creates a new channel in the given guild
// guildID : The ID of a Guild
// data : A data struct describing the new Channel, Name and Type are mandatory, other fields depending on the type
func (s *Session) GuildChannelCreateComplex(guildID string, data GuildChannelCreateData) (st *Channel, err error) {
body, err := s.RequestWithBucketID("POST", EndpointGuildChannels(guildID), data, EndpointGuildChannels(guildID))
if err != nil {
return
@ -930,6 +935,17 @@ func (s *Session) GuildChannelCreate(guildID, name string, ctype ChannelType) (s
return
}
// GuildChannelCreate creates a new channel in the given guild
// guildID : The ID of a Guild.
// name : Name of the channel (2-100 chars length)
// ctype : Type of the channel
func (s *Session) GuildChannelCreate(guildID, name string, ctype ChannelType) (st *Channel, err error) {
return s.GuildChannelCreateComplex(guildID, GuildChannelCreateData{
Name: name,
Type: ctype,
})
}
// GuildChannelsReorder updates the order of channels in a guild
// guildID : The ID of a Guild.
// channels : Updated channels.