From f124f385633b49afbc3cd5410533d560edb2d3f9 Mon Sep 17 00:00:00 2001 From: Fedor Lapshin <42876964+FedorLap2006@users.noreply.github.com> Date: Thu, 17 Dec 2020 21:59:41 +0300 Subject: [PATCH] GuildBan method and UnknownBan error code addition (#848) * UnknownBan error code addition * GuildBan method implementation * Gofmt fix Gofmt fix --- restapi.go | 13 +++++++++++++ structs.go | 1 + 2 files changed, 14 insertions(+) diff --git a/restapi.go b/restapi.go index b088711..fdbcc35 100644 --- a/restapi.go +++ b/restapi.go @@ -693,6 +693,19 @@ func (s *Session) GuildBanCreate(guildID, userID string, days int) (err error) { 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. // guildID : The ID of a Guild. // userID : The ID of a User diff --git a/structs.go b/structs.go index 91b5002..13eb993 100644 --- a/structs.go +++ b/structs.go @@ -1253,6 +1253,7 @@ const ( ErrCodeUnknownUser = 10013 ErrCodeUnknownEmoji = 10014 ErrCodeUnknownWebhook = 10015 + ErrCodeUnknownBan = 10026 ErrCodeBotsCannotUseEndpoint = 20001 ErrCodeOnlyBotsCanUseEndpoint = 20002