Merge pull request #546 from ikkerens/patch-2

Added GuildChannelCreateComplex
This commit is contained in:
Skippy 2018-08-27 11:29:35 -05:00 committed by GitHub
commit 32167eae71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -911,17 +911,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
@ -931,6 +936,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.