Update dependencies and build to go1.22 (#2113)

* Update dependencies and build to go1.22

* Fix api changes wrt to dependencies

* Update golangci config
This commit is contained in:
Wim
2024-05-23 23:44:31 +02:00
committed by GitHub
parent 56e7bd01ca
commit 2f33fe86f5
1556 changed files with 3279522 additions and 1924375 deletions

View File

@@ -424,10 +424,11 @@ func (s *Session) UserGuildMember(guildID string, options ...RequestOption) (st
}
// UserGuilds returns an array of UserGuild structures for all guilds.
// limit : The number guilds that can be returned. (max 100)
// beforeID : If provided all guilds returned will be before given ID.
// afterID : If provided all guilds returned will be after given ID.
func (s *Session) UserGuilds(limit int, beforeID, afterID string, options ...RequestOption) (st []*UserGuild, err error) {
// limit : The number guilds that can be returned. (max 200)
// beforeID : If provided all guilds returned will be before given ID.
// afterID : If provided all guilds returned will be after given ID.
// withCounts : Whether to include approximate member and presence counts or not.
func (s *Session) UserGuilds(limit int, beforeID, afterID string, withCounts bool, options ...RequestOption) (st []*UserGuild, err error) {
v := url.Values{}
@@ -440,6 +441,9 @@ func (s *Session) UserGuilds(limit int, beforeID, afterID string, options ...Req
if beforeID != "" {
v.Set("before", beforeID)
}
if withCounts {
v.Set("with_counts", "true")
}
uri := EndpointUserGuilds("@me")
@@ -672,14 +676,9 @@ func (s *Session) GuildEdit(guildID string, g *GuildParams, options ...RequestOp
// GuildDelete deletes a Guild.
// guildID : The ID of a Guild
func (s *Session) GuildDelete(guildID string, options ...RequestOption) (st *Guild, err error) {
func (s *Session) GuildDelete(guildID string, options ...RequestOption) (err error) {
body, err := s.RequestWithBucketID("DELETE", EndpointGuild(guildID), nil, EndpointGuild(guildID), options...)
if err != nil {
return
}
err = unmarshal(body, &st)
_, err = s.RequestWithBucketID("DELETE", EndpointGuild(guildID), nil, EndpointGuild(guildID), options...)
return
}
@@ -1700,13 +1699,19 @@ func (s *Session) ChannelMessageSendComplex(channelID string, data *MessageSend,
}
}
if data.StickerIDs != nil {
if len(data.StickerIDs) > 3 {
err = fmt.Errorf("cannot send more than 3 stickers")
return
}
}
var response []byte
if len(files) > 0 {
contentType, body, encodeErr := MultipartBodyWithJSON(data, files)
if encodeErr != nil {
return st, encodeErr
}
response, err = s.request("POST", endpoint, contentType, body, endpoint, 0, options...)
} else {
response, err = s.RequestWithBucketID("POST", endpoint, data, endpoint, options...)
@@ -1796,16 +1801,18 @@ func (s *Session) ChannelMessageEditComplex(m *MessageEdit, options ...RequestOp
// TODO: Remove this when compatibility is not required.
if m.Embed != nil {
if m.Embeds == nil {
m.Embeds = []*MessageEmbed{m.Embed}
m.Embeds = &[]*MessageEmbed{m.Embed}
} else {
err = fmt.Errorf("cannot specify both Embed and Embeds")
return
}
}
for _, embed := range m.Embeds {
if embed.Type == "" {
embed.Type = "rich"
if m.Embeds != nil {
for _, embed := range *m.Embeds {
if embed.Type == "" {
embed.Type = "rich"
}
}
}
@@ -2267,7 +2274,7 @@ func (s *Session) WebhookWithToken(webhookID, token string, options ...RequestOp
// webhookID: The ID of a webhook.
// name : The name of the webhook.
// avatar : The avatar of the webhook.
func (s *Session) WebhookEdit(webhookID, name, avatar, channelID string, options ...RequestOption) (st *Role, err error) {
func (s *Session) WebhookEdit(webhookID, name, avatar, channelID string, options ...RequestOption) (st *Webhook, err error) {
data := struct {
Name string `json:"name,omitempty"`
@@ -2290,14 +2297,15 @@ func (s *Session) WebhookEdit(webhookID, name, avatar, channelID string, options
// token : The auth token for the webhook.
// name : The name of the webhook.
// avatar : The avatar of the webhook.
func (s *Session) WebhookEditWithToken(webhookID, token, name, avatar string, options ...RequestOption) (st *Role, err error) {
func (s *Session) WebhookEditWithToken(webhookID, token, name, avatar string, options ...RequestOption) (st *Webhook, err error) {
data := struct {
Name string `json:"name,omitempty"`
Avatar string `json:"avatar,omitempty"`
}{name, avatar}
body, err := s.RequestWithBucketID("PATCH", EndpointWebhookToken(webhookID, token), data, EndpointWebhookToken("", ""), options...)
var body []byte
body, err = s.RequestWithBucketID("PATCH", EndpointWebhookToken(webhookID, token), data, EndpointWebhookToken("", ""), options...)
if err != nil {
return
}
@@ -2709,11 +2717,22 @@ func (s *Session) ThreadMemberRemove(threadID, memberID string, options ...Reque
return err
}
// ThreadMember returns thread member object for the specified member of a thread
func (s *Session) ThreadMember(threadID, memberID string, options ...RequestOption) (member *ThreadMember, err error) {
endpoint := EndpointThreadMember(threadID, memberID)
// ThreadMember returns thread member object for the specified member of a thread.
// withMember : Whether to include a guild member object.
func (s *Session) ThreadMember(threadID, memberID string, withMember bool, options ...RequestOption) (member *ThreadMember, err error) {
uri := EndpointThreadMember(threadID, memberID)
queryParams := url.Values{}
if withMember {
queryParams.Set("with_member", "true")
}
if len(queryParams) > 0 {
uri += "?" + queryParams.Encode()
}
var body []byte
body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...)
body, err = s.RequestWithBucketID("GET", uri, nil, uri, options...)
if err != nil {
return
@@ -2724,9 +2743,29 @@ func (s *Session) ThreadMember(threadID, memberID string, options ...RequestOpti
}
// ThreadMembers returns all members of specified thread.
func (s *Session) ThreadMembers(threadID string, options ...RequestOption) (members []*ThreadMember, err error) {
// limit : Max number of thread members to return (1-100). Defaults to 100.
// afterID : Get thread members after this user ID.
// withMember : Whether to include a guild member object for each thread member.
func (s *Session) ThreadMembers(threadID string, limit int, withMember bool, afterID string, options ...RequestOption) (members []*ThreadMember, err error) {
uri := EndpointThreadMembers(threadID)
queryParams := url.Values{}
if withMember {
queryParams.Set("with_member", "true")
}
if limit > 0 {
queryParams.Set("limit", strconv.Itoa(limit))
}
if afterID != "" {
queryParams.Set("after", afterID)
}
if len(queryParams) > 0 {
uri += "?" + queryParams.Encode()
}
var body []byte
body, err = s.RequestWithBucketID("GET", EndpointThreadMembers(threadID), nil, EndpointThreadMembers(threadID), options...)
body, err = s.RequestWithBucketID("GET", uri, nil, uri, options...)
if err != nil {
return
@@ -3248,6 +3287,37 @@ func (s *Session) GuildScheduledEventUsers(guildID, eventID string, limit int, w
return
}
// GuildOnboarding returns onboarding configuration of a guild.
// guildID : The ID of the guild
func (s *Session) GuildOnboarding(guildID string, options ...RequestOption) (onboarding *GuildOnboarding, err error) {
endpoint := EndpointGuildOnboarding(guildID)
var body []byte
body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...)
if err != nil {
return
}
err = unmarshal(body, &onboarding)
return
}
// GuildOnboardingEdit edits onboarding configuration of a guild.
// guildID : The ID of the guild
// o : New GuildOnboarding data
func (s *Session) GuildOnboardingEdit(guildID string, o *GuildOnboarding, options ...RequestOption) (onboarding *GuildOnboarding, err error) {
endpoint := EndpointGuildOnboarding(guildID)
var body []byte
body, err = s.RequestWithBucketID("PUT", endpoint, o, endpoint, options...)
if err != nil {
return
}
err = unmarshal(body, &onboarding)
return
}
// ----------------------------------------------------------------------
// Functions specific to auto moderation
// ----------------------------------------------------------------------