forked from pothtonswer/discordmuffin
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:
parent
0003ae7dd2
commit
e024d5f032
2 changed files with 21 additions and 5 deletions
14
restapi.go
14
restapi.go
|
@ -1221,12 +1221,16 @@ func (s *Session) Channel(channelID string) (st *Channel, err error) {
|
|||
// ChannelEdit edits the given channel
|
||||
// channelID : The ID of a Channel
|
||||
// name : The new name to assign the channel.
|
||||
func (s *Session) ChannelEdit(channelID, name string) (st *Channel, err error) {
|
||||
|
||||
data := struct {
|
||||
Name string `json:"name"`
|
||||
}{name}
|
||||
func (s *Session) ChannelEdit(channelID, name string) (*Channel, error) {
|
||||
return s.ChannelEditComplex(channelID, &ChannelEdit{
|
||||
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))
|
||||
if err != nil {
|
||||
return
|
||||
|
|
12
structs.go
12
structs.go
|
@ -176,6 +176,18 @@ type Channel struct {
|
|||
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
|
||||
type PermissionOverwrite struct {
|
||||
ID string `json:"id"`
|
||||
|
|
Loading…
Reference in a new issue