forked from pothtonswer/discordmuffin
Merge pull request #546 from ikkerens/patch-2
Added GuildChannelCreateComplex
This commit is contained in:
commit
32167eae71
1 changed files with 26 additions and 10 deletions
32
restapi.go
32
restapi.go
|
@ -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 {
|
||||
// GuildChannelCreateData is provided to GuildChannelCreateComplex
|
||||
type GuildChannelCreateData struct {
|
||||
Name string `json:"name"`
|
||||
Type ChannelType `json:"type"`
|
||||
}{name, ctype}
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue