Added reason go GuildBanCreate (#367)

* Added reason go GuildBanCreate

* Added GuildBanCreateWithReason
This commit is contained in:
jonas747 2017-04-29 03:41:48 +02:00 committed by Chris Rhodes
parent 7b62921b4e
commit 4fb7760b59

View file

@ -663,11 +663,28 @@ func (s *Session) GuildBans(guildID string) (st []*GuildBan, err error) {
// userID : The ID of a User
// days : The number of days of previous comments to delete.
func (s *Session) GuildBanCreate(guildID, userID string, days int) (err error) {
return s.GuildBanCreateWithReason(guildID, userID, "", days)
}
// GuildBanCreateWithReason bans the given user from the given guild also providing a reaso.
// guildID : The ID of a Guild.
// userID : The ID of a User
// reason : The reason for this ban
// days : The number of days of previous comments to delete.
func (s *Session) GuildBanCreateWithReason(guildID, userID, reason string, days int) (err error) {
uri := EndpointGuildBan(guildID, userID)
queryParams := url.Values{}
if days > 0 {
uri = fmt.Sprintf("%s?delete-message-days=%d", uri, days)
queryParams.Set("delete-message-days", strconv.Itoa(days))
}
if reason != "" {
queryParams.Set("reason", reason)
}
if len(queryParams) > 0 {
uri += "?" + queryParams.Encode()
}
_, err = s.RequestWithBucketID("PUT", uri, nil, EndpointGuildBan(guildID, ""))