GuildBan method and UnknownBan error code addition (#848)

* UnknownBan error code addition

* GuildBan method implementation

* Gofmt fix

Gofmt fix
This commit is contained in:
Fedor Lapshin 2020-12-17 21:59:41 +03:00 committed by GitHub
parent 31f70d4394
commit f124f38563
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -693,6 +693,19 @@ func (s *Session) GuildBanCreate(guildID, userID string, days int) (err error) {
return s.GuildBanCreateWithReason(guildID, userID, "", days) return s.GuildBanCreateWithReason(guildID, userID, "", days)
} }
// GuildBan finds ban by given guild and user id and returns GuildBan structure
func (s *Session) GuildBan(guildID, userID string) (st *GuildBan, err error) {
body, err := s.RequestWithBucketID("GET", EndpointGuildBan(guildID, userID), nil, EndpointGuildBan(guildID, userID))
if err != nil {
return
}
err = unmarshal(body, &st)
return
}
// GuildBanCreateWithReason bans the given user from the given guild also providing a reaso. // GuildBanCreateWithReason bans the given user from the given guild also providing a reaso.
// guildID : The ID of a Guild. // guildID : The ID of a Guild.
// userID : The ID of a User // userID : The ID of a User

View file

@ -1253,6 +1253,7 @@ const (
ErrCodeUnknownUser = 10013 ErrCodeUnknownUser = 10013
ErrCodeUnknownEmoji = 10014 ErrCodeUnknownEmoji = 10014
ErrCodeUnknownWebhook = 10015 ErrCodeUnknownWebhook = 10015
ErrCodeUnknownBan = 10026
ErrCodeBotsCannotUseEndpoint = 20001 ErrCodeBotsCannotUseEndpoint = 20001
ErrCodeOnlyBotsCanUseEndpoint = 20002 ErrCodeOnlyBotsCanUseEndpoint = 20002