forked from pothtonswer/discordmuffin
Added reason go GuildBanCreate (#367)
* Added reason go GuildBanCreate * Added GuildBanCreateWithReason
This commit is contained in:
parent
7b62921b4e
commit
4fb7760b59
1 changed files with 18 additions and 1 deletions
19
restapi.go
19
restapi.go
|
@ -663,11 +663,28 @@ func (s *Session) GuildBans(guildID string) (st []*GuildBan, err error) {
|
||||||
// userID : The ID of a User
|
// userID : The ID of a User
|
||||||
// days : The number of days of previous comments to delete.
|
// days : The number of days of previous comments to delete.
|
||||||
func (s *Session) GuildBanCreate(guildID, userID string, days int) (err error) {
|
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)
|
uri := EndpointGuildBan(guildID, userID)
|
||||||
|
|
||||||
|
queryParams := url.Values{}
|
||||||
if days > 0 {
|
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, ""))
|
_, err = s.RequestWithBucketID("PUT", uri, nil, EndpointGuildBan(guildID, ""))
|
||||||
|
|
Loading…
Reference in a new issue