summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/bwmarrin/discordgo
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/bwmarrin/discordgo')
-rw-r--r--vendor/github.com/bwmarrin/discordgo/components.go46
-rw-r--r--vendor/github.com/bwmarrin/discordgo/discord.go2
-rw-r--r--vendor/github.com/bwmarrin/discordgo/endpoints.go17
-rw-r--r--vendor/github.com/bwmarrin/discordgo/events.go15
-rw-r--r--vendor/github.com/bwmarrin/discordgo/interactions.go16
-rw-r--r--vendor/github.com/bwmarrin/discordgo/message.go8
-rw-r--r--vendor/github.com/bwmarrin/discordgo/restapi.go1067
-rw-r--r--vendor/github.com/bwmarrin/discordgo/state.go33
-rw-r--r--vendor/github.com/bwmarrin/discordgo/structs.go299
-rw-r--r--vendor/github.com/bwmarrin/discordgo/util.go18
-rw-r--r--vendor/github.com/bwmarrin/discordgo/voice.go21
-rw-r--r--vendor/github.com/bwmarrin/discordgo/wsapi.go10
12 files changed, 1029 insertions, 523 deletions
diff --git a/vendor/github.com/bwmarrin/discordgo/components.go b/vendor/github.com/bwmarrin/discordgo/components.go
index 6ee4e289..a5f86b34 100644
--- a/vendor/github.com/bwmarrin/discordgo/components.go
+++ b/vendor/github.com/bwmarrin/discordgo/components.go
@@ -10,10 +10,14 @@ type ComponentType uint
// MessageComponent types.
const (
- ActionsRowComponent ComponentType = 1
- ButtonComponent ComponentType = 2
- SelectMenuComponent ComponentType = 3
- TextInputComponent ComponentType = 4
+ ActionsRowComponent ComponentType = 1
+ ButtonComponent ComponentType = 2
+ SelectMenuComponent ComponentType = 3
+ TextInputComponent ComponentType = 4
+ UserSelectMenuComponent ComponentType = 5
+ RoleSelectMenuComponent ComponentType = 6
+ MentionableSelectMenuComponent ComponentType = 7
+ ChannelSelectMenuComponent ComponentType = 8
)
// MessageComponent is a base interface for all message components.
@@ -41,7 +45,8 @@ func (umc *unmarshalableMessageComponent) UnmarshalJSON(src []byte) error {
umc.MessageComponent = &ActionsRow{}
case ButtonComponent:
umc.MessageComponent = &Button{}
- case SelectMenuComponent:
+ case SelectMenuComponent, ChannelSelectMenuComponent, UserSelectMenuComponent,
+ RoleSelectMenuComponent, MentionableSelectMenuComponent:
umc.MessageComponent = &SelectMenu{}
case TextInputComponent:
umc.MessageComponent = &TextInput{}
@@ -169,8 +174,23 @@ type SelectMenuOption struct {
Default bool `json:"default"`
}
+// SelectMenuType represents select menu type.
+type SelectMenuType ComponentType
+
+// SelectMenu types.
+const (
+ StringSelectMenu = SelectMenuType(SelectMenuComponent)
+ UserSelectMenu = SelectMenuType(UserSelectMenuComponent)
+ RoleSelectMenu = SelectMenuType(RoleSelectMenuComponent)
+ MentionableSelectMenu = SelectMenuType(MentionableSelectMenuComponent)
+ ChannelSelectMenu = SelectMenuType(ChannelSelectMenuComponent)
+)
+
// SelectMenu represents select menu component.
type SelectMenu struct {
+ // Type of the select menu.
+ MenuType SelectMenuType `json:"type,omitempty"`
+ // CustomID is a developer-defined identifier for the select menu.
CustomID string `json:"custom_id,omitempty"`
// The text which will be shown in the menu if there's no default options or all options was deselected and component was closed.
Placeholder string `json:"placeholder"`
@@ -179,25 +199,31 @@ type SelectMenu struct {
// This value determines the maximal amount of selected items in the menu.
// If MaxValues or MinValues are greater than one then the user can select multiple items in the component.
MaxValues int `json:"max_values,omitempty"`
- Options []SelectMenuOption `json:"options"`
+ Options []SelectMenuOption `json:"options,omitempty"`
Disabled bool `json:"disabled"`
+
+ // NOTE: Can only be used in SelectMenu with Channel menu type.
+ ChannelTypes []ChannelType `json:"channel_types,omitempty"`
}
// Type is a method to get the type of a component.
-func (SelectMenu) Type() ComponentType {
+func (s SelectMenu) Type() ComponentType {
+ if s.MenuType != 0 {
+ return ComponentType(s.MenuType)
+ }
return SelectMenuComponent
}
// MarshalJSON is a method for marshaling SelectMenu to a JSON object.
-func (m SelectMenu) MarshalJSON() ([]byte, error) {
+func (s SelectMenu) MarshalJSON() ([]byte, error) {
type selectMenu SelectMenu
return Marshal(struct {
selectMenu
Type ComponentType `json:"type"`
}{
- selectMenu: selectMenu(m),
- Type: m.Type(),
+ selectMenu: selectMenu(s),
+ Type: s.Type(),
})
}
diff --git a/vendor/github.com/bwmarrin/discordgo/discord.go b/vendor/github.com/bwmarrin/discordgo/discord.go
index fc7b6d7a..0b571764 100644
--- a/vendor/github.com/bwmarrin/discordgo/discord.go
+++ b/vendor/github.com/bwmarrin/discordgo/discord.go
@@ -22,7 +22,7 @@ import (
)
// VERSION of DiscordGo, follows Semantic Versioning. (http://semver.org/)
-const VERSION = "0.26.1"
+const VERSION = "0.27.0"
// New creates a new Discord session with provided token.
// If the token is for a bot, it must be prefixed with "Bot "
diff --git a/vendor/github.com/bwmarrin/discordgo/endpoints.go b/vendor/github.com/bwmarrin/discordgo/endpoints.go
index 375b75b5..a2a05fe3 100644
--- a/vendor/github.com/bwmarrin/discordgo/endpoints.go
+++ b/vendor/github.com/bwmarrin/discordgo/endpoints.go
@@ -60,11 +60,12 @@ var (
return EndpointCDNBanners + uID + "/" + cID + ".gif"
}
- EndpointUserGuilds = func(uID string) string { return EndpointUsers + uID + "/guilds" }
- EndpointUserGuild = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID }
- EndpointUserGuildMember = func(uID, gID string) string { return EndpointUserGuild(uID, gID) + "/member" }
- EndpointUserChannels = func(uID string) string { return EndpointUsers + uID + "/channels" }
- EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" }
+ EndpointUserGuilds = func(uID string) string { return EndpointUsers + uID + "/guilds" }
+ EndpointUserGuild = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID }
+ EndpointUserGuildMember = func(uID, gID string) string { return EndpointUserGuild(uID, gID) + "/member" }
+ EndpointUserChannels = func(uID string) string { return EndpointUsers + uID + "/channels" }
+ EndpointUserApplicationRoleConnection = func(aID string) string { return EndpointUsers + "@me/applications/" + aID + "/role-connection" }
+ EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" }
EndpointGuild = func(gID string) string { return EndpointGuilds + gID }
EndpointGuildAutoModeration = func(gID string) string { return EndpointGuild(gID) + "/auto-moderation" }
@@ -96,6 +97,7 @@ var (
EndpointGuildEmojis = func(gID string) string { return EndpointGuilds + gID + "/emojis" }
EndpointGuildEmoji = func(gID, eID string) string { return EndpointGuilds + gID + "/emojis/" + eID }
EndpointGuildBanner = func(gID, hash string) string { return EndpointCDNBanners + gID + "/" + hash + ".png" }
+ EndpointGuildBannerAnimated = func(gID, hash string) string { return EndpointCDNBanners + gID + "/" + hash + ".gif" }
EndpointGuildStickers = func(gID string) string { return EndpointGuilds + gID + "/stickers" }
EndpointGuildSticker = func(gID, sID string) string { return EndpointGuilds + gID + "/stickers/" + sID }
EndpointStageInstance = func(cID string) string { return EndpointStageInstances + "/" + cID }
@@ -197,8 +199,9 @@ var (
EndpointEmoji = func(eID string) string { return EndpointCDN + "emojis/" + eID + ".png" }
EndpointEmojiAnimated = func(eID string) string { return EndpointCDN + "emojis/" + eID + ".gif" }
- EndpointApplications = EndpointAPI + "applications"
- EndpointApplication = func(aID string) string { return EndpointApplications + "/" + aID }
+ EndpointApplications = EndpointAPI + "applications"
+ EndpointApplication = func(aID string) string { return EndpointApplications + "/" + aID }
+ EndpointApplicationRoleConnectionMetadata = func(aID string) string { return EndpointApplication(aID) + "/role-connections/metadata" }
EndpointOAuth2 = EndpointAPI + "oauth2/"
EndpointOAuth2Applications = EndpointOAuth2 + "applications"
diff --git a/vendor/github.com/bwmarrin/discordgo/events.go b/vendor/github.com/bwmarrin/discordgo/events.go
index e5d83b9b..6608ab6e 100644
--- a/vendor/github.com/bwmarrin/discordgo/events.go
+++ b/vendor/github.com/bwmarrin/discordgo/events.go
@@ -36,13 +36,13 @@ type Event struct {
// A Ready stores all data for the websocket READY event.
type Ready struct {
- Version int `json:"v"`
- SessionID string `json:"session_id"`
- User *User `json:"user"`
- Guilds []*Guild `json:"guilds"`
- PrivateChannels []*Channel `json:"private_channels"`
-
- // TODO: Application and Shard
+ Version int `json:"v"`
+ SessionID string `json:"session_id"`
+ User *User `json:"user"`
+ Shard *[2]int `json:"shard"`
+ Application *Application `json:"application"`
+ Guilds []*Guild `json:"guilds"`
+ PrivateChannels []*Channel `json:"private_channels"`
}
// ChannelCreate is the data for a ChannelCreate event.
@@ -150,6 +150,7 @@ type GuildMemberAdd struct {
// GuildMemberUpdate is the data for a GuildMemberUpdate event.
type GuildMemberUpdate struct {
*Member
+ BeforeUpdate *Member `json:"-"`
}
// GuildMemberRemove is the data for a GuildMemberRemove event.
diff --git a/vendor/github.com/bwmarrin/discordgo/interactions.go b/vendor/github.com/bwmarrin/discordgo/interactions.go
index 61a4e992..627e0c38 100644
--- a/vendor/github.com/bwmarrin/discordgo/interactions.go
+++ b/vendor/github.com/bwmarrin/discordgo/interactions.go
@@ -42,6 +42,7 @@ type ApplicationCommand struct {
DefaultPermission *bool `json:"default_permission,omitempty"`
DefaultMemberPermissions *int64 `json:"default_member_permissions,string,omitempty"`
DMPermission *bool `json:"dm_permission,omitempty"`
+ NSFW *bool `json:"nsfw,omitempty"`
// NOTE: Chat commands only. Otherwise it mustn't be set.
@@ -343,13 +344,22 @@ func (ApplicationCommandInteractionData) Type() InteractionType {
// MessageComponentInteractionData contains the data of message component interaction.
type MessageComponentInteractionData struct {
- CustomID string `json:"custom_id"`
- ComponentType ComponentType `json:"component_type"`
+ CustomID string `json:"custom_id"`
+ ComponentType ComponentType `json:"component_type"`
+ Resolved MessageComponentInteractionDataResolved `json:"resolved"`
// NOTE: Only filled when ComponentType is SelectMenuComponent (3). Otherwise is nil.
Values []string `json:"values"`
}
+// MessageComponentInteractionDataResolved contains the resolved data of selected option.
+type MessageComponentInteractionDataResolved struct {
+ Users map[string]*User `json:"users"`
+ Members map[string]*Member `json:"members"`
+ Roles map[string]*Role `json:"roles"`
+ Channels map[string]*Channel `json:"channels"`
+}
+
// Type returns the type of interaction data.
func (MessageComponentInteractionData) Type() InteractionType {
return InteractionMessageComponent
@@ -472,7 +482,7 @@ func (o ApplicationCommandInteractionDataOption) RoleValue(s *Session, gID strin
return &Role{ID: roleID}
}
- r, err := s.State.Role(roleID, gID)
+ r, err := s.State.Role(gID, roleID)
if err != nil {
roles, err := s.GuildRoles(gID)
if err == nil {
diff --git a/vendor/github.com/bwmarrin/discordgo/message.go b/vendor/github.com/bwmarrin/discordgo/message.go
index 1ba6e445..fec6f879 100644
--- a/vendor/github.com/bwmarrin/discordgo/message.go
+++ b/vendor/github.com/bwmarrin/discordgo/message.go
@@ -249,6 +249,10 @@ type MessageEdit struct {
Embeds []*MessageEmbed `json:"embeds"`
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
Flags MessageFlags `json:"flags,omitempty"`
+ // Files to append to the message
+ Files []*File `json:"-"`
+ // Overwrite existing attachments
+ Attachments *[]*MessageAttachment `json:"attachments,omitempty"`
ID string
Channel string
@@ -385,8 +389,8 @@ type MessageEmbedAuthor struct {
// MessageEmbedField is a part of a MessageEmbed struct.
type MessageEmbedField struct {
- Name string `json:"name,omitempty"`
- Value string `json:"value,omitempty"`
+ Name string `json:"name"`
+ Value string `json:"value"`
Inline bool `json:"inline,omitempty"`
}
diff --git a/vendor/github.com/bwmarrin/discordgo/restapi.go b/vendor/github.com/bwmarrin/discordgo/restapi.go
index 79af4680..b7d323e7 100644
--- a/vendor/github.com/bwmarrin/discordgo/restapi.go
+++ b/vendor/github.com/bwmarrin/discordgo/restapi.go
@@ -26,6 +26,8 @@ import (
"strconv"
"strings"
"time"
+
+ "context"
)
// All error constants
@@ -92,13 +94,82 @@ func (e RateLimitError) Error() string {
return "Rate limit exceeded on " + e.URL + ", retry after " + e.RetryAfter.String()
}
+// RequestConfig is an HTTP request configuration.
+type RequestConfig struct {
+ Request *http.Request
+ ShouldRetryOnRateLimit bool
+ MaxRestRetries int
+ Client *http.Client
+}
+
+// newRequestConfig returns a new HTTP request configuration based on parameters in Session.
+func newRequestConfig(s *Session, req *http.Request) *RequestConfig {
+ return &RequestConfig{
+ ShouldRetryOnRateLimit: s.ShouldRetryOnRateLimit,
+ MaxRestRetries: s.MaxRestRetries,
+ Client: s.Client,
+ Request: req,
+ }
+}
+
+// RequestOption is a function which mutates request configuration.
+// It can be supplied as an argument to any REST method.
+type RequestOption func(cfg *RequestConfig)
+
+// WithClient changes the HTTP client used for the request.
+func WithClient(client *http.Client) RequestOption {
+ return func(cfg *RequestConfig) {
+ if client != nil {
+ cfg.Client = client
+ }
+ }
+}
+
+// WithRetryOnRatelimit controls whether session will retry the request on rate limit.
+func WithRetryOnRatelimit(retry bool) RequestOption {
+ return func(cfg *RequestConfig) {
+ cfg.ShouldRetryOnRateLimit = retry
+ }
+}
+
+// WithRestRetries changes maximum amount of retries if request fails.
+func WithRestRetries(max int) RequestOption {
+ return func(cfg *RequestConfig) {
+ cfg.MaxRestRetries = max
+ }
+}
+
+// WithHeader sets a header in the request.
+func WithHeader(key, value string) RequestOption {
+ return func(cfg *RequestConfig) {
+ cfg.Request.Header.Set(key, value)
+ }
+}
+
+// WithAuditLogReason changes audit log reason associated with the request.
+func WithAuditLogReason(reason string) RequestOption {
+ return WithHeader("X-Audit-Log-Reason", reason)
+}
+
+// WithLocale changes accepted locale of the request.
+func WithLocale(locale Locale) RequestOption {
+ return WithHeader("X-Discord-Locale", string(locale))
+}
+
+// WithContext changes context of the request.
+func WithContext(ctx context.Context) RequestOption {
+ return func(cfg *RequestConfig) {
+ cfg.Request = cfg.Request.WithContext(ctx)
+ }
+}
+
// Request is the same as RequestWithBucketID but the bucket id is the same as the urlStr
-func (s *Session) Request(method, urlStr string, data interface{}) (response []byte, err error) {
- return s.RequestWithBucketID(method, urlStr, data, strings.SplitN(urlStr, "?", 2)[0])
+func (s *Session) Request(method, urlStr string, data interface{}, options ...RequestOption) (response []byte, err error) {
+ return s.RequestWithBucketID(method, urlStr, data, strings.SplitN(urlStr, "?", 2)[0], options...)
}
// RequestWithBucketID makes a (GET/POST/...) Requests to Discord REST API with JSON data.
-func (s *Session) RequestWithBucketID(method, urlStr string, data interface{}, bucketID string) (response []byte, err error) {
+func (s *Session) RequestWithBucketID(method, urlStr string, data interface{}, bucketID string, options ...RequestOption) (response []byte, err error) {
var body []byte
if data != nil {
body, err = Marshal(data)
@@ -107,21 +178,21 @@ func (s *Session) RequestWithBucketID(method, urlStr string, data interface{}, b
}
}
- return s.request(method, urlStr, "application/json", body, bucketID, 0)
+ return s.request(method, urlStr, "application/json", body, bucketID, 0, options...)
}
// request makes a (GET/POST/...) Requests to Discord REST API.
// Sequence is the sequence number, if it fails with a 502 it will
// retry with sequence+1 until it either succeeds or sequence >= session.MaxRestRetries
-func (s *Session) request(method, urlStr, contentType string, b []byte, bucketID string, sequence int) (response []byte, err error) {
+func (s *Session) request(method, urlStr, contentType string, b []byte, bucketID string, sequence int, options ...RequestOption) (response []byte, err error) {
if bucketID == "" {
bucketID = strings.SplitN(urlStr, "?", 2)[0]
}
- return s.RequestWithLockedBucket(method, urlStr, contentType, b, s.Ratelimiter.LockBucket(bucketID), sequence)
+ return s.RequestWithLockedBucket(method, urlStr, contentType, b, s.Ratelimiter.LockBucket(bucketID), sequence, options...)
}
// RequestWithLockedBucket makes a request using a bucket that's already been locked
-func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b []byte, bucket *Bucket, sequence int) (response []byte, err error) {
+func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b []byte, bucket *Bucket, sequence int, options ...RequestOption) (response []byte, err error) {
if s.Debug {
log.Printf("API REQUEST %8s :: %s\n", method, urlStr)
log.Printf("API REQUEST PAYLOAD :: [%s]\n", string(b))
@@ -148,13 +219,18 @@ func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b
// TODO: Make a configurable static variable.
req.Header.Set("User-Agent", s.UserAgent)
+ cfg := newRequestConfig(s, req)
+ for _, opt := range options {
+ opt(cfg)
+ }
+
if s.Debug {
for k, v := range req.Header {
log.Printf("API REQUEST HEADER :: [%s] = %+v\n", k, v)
}
}
- resp, err := s.Client.Do(req)
+ resp, err := cfg.Client.Do(req)
if err != nil {
bucket.Release(nil)
return
@@ -191,10 +267,10 @@ func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b
case http.StatusNoContent:
case http.StatusBadGateway:
// Retry sending request if possible
- if sequence < s.MaxRestRetries {
+ if sequence < cfg.MaxRestRetries {
s.log(LogInformational, "%s Failed (%s), Retrying...", urlStr, resp.Status)
- response, err = s.RequestWithLockedBucket(method, urlStr, contentType, b, s.Ratelimiter.LockBucketObject(bucket), sequence+1)
+ response, err = s.RequestWithLockedBucket(method, urlStr, contentType, b, s.Ratelimiter.LockBucketObject(bucket), sequence+1, options...)
} else {
err = fmt.Errorf("Exceeded Max retries HTTP %s, %s", resp.Status, response)
}
@@ -206,7 +282,7 @@ func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b
return
}
- if s.ShouldRetryOnRateLimit {
+ if cfg.ShouldRetryOnRateLimit {
s.log(LogInformational, "Rate Limiting %s, retry in %v", urlStr, rl.RetryAfter)
s.handleEvent(rateLimitEventType, &RateLimit{TooManyRequests: &rl, URL: urlStr})
@@ -214,7 +290,7 @@ func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b
// we can make the above smarter
// this method can cause longer delays than required
- response, err = s.RequestWithLockedBucket(method, urlStr, contentType, b, s.Ratelimiter.LockBucketObject(bucket), sequence)
+ response, err = s.RequestWithLockedBucket(method, urlStr, contentType, b, s.Ratelimiter.LockBucketObject(bucket), sequence, options...)
} else {
err = &RateLimitError{&RateLimit{TooManyRequests: &rl, URL: urlStr}}
}
@@ -246,9 +322,9 @@ func unmarshal(data []byte, v interface{}) error {
// User returns the user details of the given userID
// userID : A user ID or "@me" which is a shortcut of current user ID
-func (s *Session) User(userID string) (st *User, err error) {
+func (s *Session) User(userID string, options ...RequestOption) (st *User, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointUser(userID), nil, EndpointUsers)
+ body, err := s.RequestWithBucketID("GET", EndpointUser(userID), nil, EndpointUsers, options...)
if err != nil {
return
}
@@ -259,19 +335,19 @@ func (s *Session) User(userID string) (st *User, err error) {
// UserAvatar is deprecated. Please use UserAvatarDecode
// userID : A user ID or "@me" which is a shortcut of current user ID
-func (s *Session) UserAvatar(userID string) (img image.Image, err error) {
- u, err := s.User(userID)
+func (s *Session) UserAvatar(userID string, options ...RequestOption) (img image.Image, err error) {
+ u, err := s.User(userID, options...)
if err != nil {
return
}
- img, err = s.UserAvatarDecode(u)
+ img, err = s.UserAvatarDecode(u, options...)
return
}
// UserAvatarDecode returns an image.Image of a user's Avatar
// user : The user which avatar should be retrieved
-func (s *Session) UserAvatarDecode(u *User) (img image.Image, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointUserAvatar(u.ID, u.Avatar), nil, EndpointUserAvatar("", ""))
+func (s *Session) UserAvatarDecode(u *User, options ...RequestOption) (img image.Image, err error) {
+ body, err := s.RequestWithBucketID("GET", EndpointUserAvatar(u.ID, u.Avatar), nil, EndpointUserAvatar("", ""), options...)
if err != nil {
return
}
@@ -281,7 +357,7 @@ func (s *Session) UserAvatarDecode(u *User) (img image.Image, err error) {
}
// UserUpdate updates current user settings.
-func (s *Session) UserUpdate(username, avatar string) (st *User, err error) {
+func (s *Session) UserUpdate(username, avatar string, options ...RequestOption) (st *User, err error) {
// NOTE: Avatar must be either the hash/id of existing Avatar or
// data:image/png;base64,BASE64_STRING_OF_NEW_AVATAR_PNG
@@ -293,7 +369,7 @@ func (s *Session) UserUpdate(username, avatar string) (st *User, err error) {
Avatar string `json:"avatar,omitempty"`
}{username, avatar}
- body, err := s.RequestWithBucketID("PATCH", EndpointUser("@me"), data, EndpointUsers)
+ body, err := s.RequestWithBucketID("PATCH", EndpointUser("@me"), data, EndpointUsers, options...)
if err != nil {
return
}
@@ -303,8 +379,8 @@ func (s *Session) UserUpdate(username, avatar string) (st *User, err error) {
}
// UserConnections returns the user's connections
-func (s *Session) UserConnections() (conn []*UserConnection, err error) {
- response, err := s.RequestWithBucketID("GET", EndpointUserConnections("@me"), nil, EndpointUserConnections("@me"))
+func (s *Session) UserConnections(options ...RequestOption) (conn []*UserConnection, err error) {
+ response, err := s.RequestWithBucketID("GET", EndpointUserConnections("@me"), nil, EndpointUserConnections("@me"), options...)
if err != nil {
return nil, err
}
@@ -319,13 +395,13 @@ func (s *Session) UserConnections() (conn []*UserConnection, err error) {
// UserChannelCreate creates a new User (Private) Channel with another User
// recipientID : A user ID for the user to which this channel is opened with.
-func (s *Session) UserChannelCreate(recipientID string) (st *Channel, err error) {
+func (s *Session) UserChannelCreate(recipientID string, options ...RequestOption) (st *Channel, err error) {
data := struct {
RecipientID string `json:"recipient_id"`
}{recipientID}
- body, err := s.RequestWithBucketID("POST", EndpointUserChannels("@me"), data, EndpointUserChannels(""))
+ body, err := s.RequestWithBucketID("POST", EndpointUserChannels("@me"), data, EndpointUserChannels(""), options...)
if err != nil {
return
}
@@ -336,8 +412,8 @@ func (s *Session) UserChannelCreate(recipientID string) (st *Channel, err error)
// UserGuildMember returns a guild member object for the current user in the given Guild.
// guildID : ID of the guild
-func (s *Session) UserGuildMember(guildID string) (st *Member, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointUserGuildMember("@me", guildID), nil, EndpointUserGuildMember("@me", guildID))
+func (s *Session) UserGuildMember(guildID string, options ...RequestOption) (st *Member, err error) {
+ body, err := s.RequestWithBucketID("GET", EndpointUserGuildMember("@me", guildID), nil, EndpointUserGuildMember("@me", guildID), options...)
if err != nil {
return
}
@@ -350,7 +426,7 @@ func (s *Session) UserGuildMember(guildID string) (st *Member, err error) {
// 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) (st []*UserGuild, err error) {
+func (s *Session) UserGuilds(limit int, beforeID, afterID string, options ...RequestOption) (st []*UserGuild, err error) {
v := url.Values{}
@@ -370,7 +446,7 @@ func (s *Session) UserGuilds(limit int, beforeID, afterID string) (st []*UserGui
uri += "?" + v.Encode()
}
- body, err := s.RequestWithBucketID("GET", uri, nil, EndpointUserGuilds(""))
+ body, err := s.RequestWithBucketID("GET", uri, nil, EndpointUserGuilds(""), options...)
if err != nil {
return
}
@@ -380,12 +456,13 @@ func (s *Session) UserGuilds(limit int, beforeID, afterID string) (st []*UserGui
}
// UserChannelPermissions returns the permission of a user in a channel.
-// userID : The ID of the user to calculate permissions for.
-// channelID : The ID of the channel to calculate permission for.
+// userID : The ID of the user to calculate permissions for.
+// channelID : The ID of the channel to calculate permission for.
+// fetchOptions : Options used to fetch guild, member or channel if they are not present in state.
//
// NOTE: This function is now deprecated and will be removed in the future.
// Please see the same function inside state.go
-func (s *Session) UserChannelPermissions(userID, channelID string) (apermissions int64, err error) {
+func (s *Session) UserChannelPermissions(userID, channelID string, fetchOptions ...RequestOption) (apermissions int64, err error) {
// Try to just get permissions from state.
apermissions, err = s.State.UserChannelPermissions(userID, channelID)
if err == nil {
@@ -395,7 +472,7 @@ func (s *Session) UserChannelPermissions(userID, channelID string) (apermissions
// Otherwise try get as much data from state as possible, falling back to the network.
channel, err := s.State.Channel(channelID)
if err != nil || channel == nil {
- channel, err = s.Channel(channelID)
+ channel, err = s.Channel(channelID, fetchOptions...)
if err != nil {
return
}
@@ -403,7 +480,7 @@ func (s *Session) UserChannelPermissions(userID, channelID string) (apermissions
guild, err := s.State.Guild(channel.GuildID)
if err != nil || guild == nil {
- guild, err = s.Guild(channel.GuildID)
+ guild, err = s.Guild(channel.GuildID, fetchOptions...)
if err != nil {
return
}
@@ -416,7 +493,7 @@ func (s *Session) UserChannelPermissions(userID, channelID string) (apermissions
member, err := s.State.Member(guild.ID, userID)
if err != nil || member == nil {
- member, err = s.GuildMember(guild.ID, userID)
+ member, err = s.GuildMember(guild.ID, userID, fetchOptions...)
if err != nil {
return
}
@@ -498,8 +575,8 @@ func memberPermissions(guild *Guild, channel *Channel, userID string, roles []st
// Guild returns a Guild structure of a specific Guild.
// guildID : The ID of a Guild
-func (s *Session) Guild(guildID string) (st *Guild, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuild(guildID), nil, EndpointGuild(guildID))
+func (s *Session) Guild(guildID string, options ...RequestOption) (st *Guild, err error) {
+ body, err := s.RequestWithBucketID("GET", EndpointGuild(guildID), nil, EndpointGuild(guildID), options...)
if err != nil {
return
}
@@ -510,9 +587,9 @@ func (s *Session) Guild(guildID string) (st *Guild, err error) {
// GuildWithCounts returns a Guild structure of a specific Guild with approximate member and presence counts.
// guildID : The ID of a Guild
-func (s *Session) GuildWithCounts(guildID string) (st *Guild, err error) {
+func (s *Session) GuildWithCounts(guildID string, options ...RequestOption) (st *Guild, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuild(guildID)+"?with_counts=true", nil, EndpointGuild(guildID))
+ body, err := s.RequestWithBucketID("GET", EndpointGuild(guildID)+"?with_counts=true", nil, EndpointGuild(guildID), options...)
if err != nil {
return
}
@@ -523,8 +600,8 @@ func (s *Session) GuildWithCounts(guildID string) (st *Guild, err error) {
// GuildPreview returns a GuildPreview structure of a specific public Guild.
// guildID : The ID of a Guild
-func (s *Session) GuildPreview(guildID string) (st *GuildPreview, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuildPreview(guildID), nil, EndpointGuildPreview(guildID))
+func (s *Session) GuildPreview(guildID string, options ...RequestOption) (st *GuildPreview, err error) {
+ body, err := s.RequestWithBucketID("GET", EndpointGuildPreview(guildID), nil, EndpointGuildPreview(guildID), options...)
if err != nil {
return
}
@@ -535,13 +612,13 @@ func (s *Session) GuildPreview(guildID string) (st *GuildPreview, err error) {
// GuildCreate creates a new Guild
// name : A name for the Guild (2-100 characters)
-func (s *Session) GuildCreate(name string) (st *Guild, err error) {
+func (s *Session) GuildCreate(name string, options ...RequestOption) (st *Guild, err error) {
data := struct {
Name string `json:"name"`
}{name}
- body, err := s.RequestWithBucketID("POST", EndpointGuildCreate, data, EndpointGuildCreate)
+ body, err := s.RequestWithBucketID("POST", EndpointGuildCreate, data, EndpointGuildCreate, options...)
if err != nil {
return
}
@@ -553,7 +630,7 @@ func (s *Session) GuildCreate(name string) (st *Guild, err error) {
// GuildEdit edits a new Guild
// guildID : The ID of a Guild
// g : A GuildParams struct with the values Name, Region and VerificationLevel defined.
-func (s *Session) GuildEdit(guildID string, g *GuildParams) (st *Guild, err error) {
+func (s *Session) GuildEdit(guildID string, g *GuildParams, options ...RequestOption) (st *Guild, err error) {
// Bounds checking for VerificationLevel, interval: [0, 4]
if g.VerificationLevel != nil {
@@ -567,7 +644,7 @@ func (s *Session) GuildEdit(guildID string, g *GuildParams) (st *Guild, err erro
// Bounds checking for regions
if g.Region != "" {
isValid := false
- regions, _ := s.VoiceRegions()
+ regions, _ := s.VoiceRegions(options...)
for _, r := range regions {
if g.Region == r.ID {
isValid = true
@@ -583,7 +660,7 @@ func (s *Session) GuildEdit(guildID string, g *GuildParams) (st *Guild, err erro
}
}
- body, err := s.RequestWithBucketID("PATCH", EndpointGuild(guildID), g, EndpointGuild(guildID))
+ body, err := s.RequestWithBucketID("PATCH", EndpointGuild(guildID), g, EndpointGuild(guildID), options...)
if err != nil {
return
}
@@ -594,9 +671,9 @@ func (s *Session) GuildEdit(guildID string, g *GuildParams) (st *Guild, err erro
// GuildDelete deletes a Guild.
// guildID : The ID of a Guild
-func (s *Session) GuildDelete(guildID string) (st *Guild, err error) {
+func (s *Session) GuildDelete(guildID string, options ...RequestOption) (st *Guild, err error) {
- body, err := s.RequestWithBucketID("DELETE", EndpointGuild(guildID), nil, EndpointGuild(guildID))
+ body, err := s.RequestWithBucketID("DELETE", EndpointGuild(guildID), nil, EndpointGuild(guildID), options...)
if err != nil {
return
}
@@ -607,18 +684,18 @@ func (s *Session) GuildDelete(guildID string) (st *Guild, err error) {
// GuildLeave leaves a Guild.
// guildID : The ID of a Guild
-func (s *Session) GuildLeave(guildID string) (err error) {
+func (s *Session) GuildLeave(guildID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointUserGuild("@me", guildID), nil, EndpointUserGuild("", guildID))
+ _, err = s.RequestWithBucketID("DELETE", EndpointUserGuild("@me", guildID), nil, EndpointUserGuild("", guildID), options...)
return
}
// GuildBans returns an array of GuildBan structures for bans in the given guild.
-// guildID : The ID of a Guild
-// limit : Max number of bans to return (max 1000)
-// beforeID : If not empty all returned users will be after the given id
-// afterID : If not empty all returned users will be before the given id
-func (s *Session) GuildBans(guildID string, limit int, beforeID, afterID string) (st []*GuildBan, err error) {
+// guildID : The ID of a Guild
+// limit : Max number of bans to return (max 1000)
+// beforeID : If not empty all returned users will be after the given id
+// afterID : If not empty all returned users will be before the given id
+func (s *Session) GuildBans(guildID string, limit int, beforeID, afterID string, options ...RequestOption) (st []*GuildBan, err error) {
uri := EndpointGuildBans(guildID)
v := url.Values{}
@@ -636,7 +713,7 @@ func (s *Session) GuildBans(guildID string, limit int, beforeID, afterID string)
uri += "?" + v.Encode()
}
- body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildBans(guildID))
+ body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildBans(guildID), options...)
if err != nil {
return
}
@@ -650,14 +727,14 @@ func (s *Session) GuildBans(guildID string, limit int, beforeID, afterID string)
// guildID : The ID of a Guild.
// 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)
+func (s *Session) GuildBanCreate(guildID, userID string, days int, options ...RequestOption) (err error) {
+ return s.GuildBanCreateWithReason(guildID, userID, "", days, options...)
}
// GuildBan finds ban by given guild and user id and returns GuildBan structure
-func (s *Session) GuildBan(guildID, userID string) (st *GuildBan, err error) {
+func (s *Session) GuildBan(guildID, userID string, options ...RequestOption) (st *GuildBan, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuildBan(guildID, userID), nil, EndpointGuildBan(guildID, userID))
+ body, err := s.RequestWithBucketID("GET", EndpointGuildBan(guildID, userID), nil, EndpointGuildBan(guildID, userID), options...)
if err != nil {
return
}
@@ -672,7 +749,7 @@ func (s *Session) GuildBan(guildID, userID string) (st *GuildBan, err error) {
// 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) {
+func (s *Session) GuildBanCreateWithReason(guildID, userID, reason string, days int, options ...RequestOption) (err error) {
uri := EndpointGuildBan(guildID, userID)
@@ -688,24 +765,24 @@ func (s *Session) GuildBanCreateWithReason(guildID, userID, reason string, days
uri += "?" + queryParams.Encode()
}
- _, err = s.RequestWithBucketID("PUT", uri, nil, EndpointGuildBan(guildID, ""))
+ _, err = s.RequestWithBucketID("PUT", uri, nil, EndpointGuildBan(guildID, ""), options...)
return
}
// GuildBanDelete removes the given user from the guild bans
// guildID : The ID of a Guild.
// userID : The ID of a User
-func (s *Session) GuildBanDelete(guildID, userID string) (err error) {
+func (s *Session) GuildBanDelete(guildID, userID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointGuildBan(guildID, userID), nil, EndpointGuildBan(guildID, ""))
+ _, err = s.RequestWithBucketID("DELETE", EndpointGuildBan(guildID, userID), nil, EndpointGuildBan(guildID, ""), options...)
return
}
// GuildMembers returns a list of members for a guild.
-// guildID : The ID of a Guild.
-// after : The id of the member to return members after
-// limit : max number of members to return (max 1000)
-func (s *Session) GuildMembers(guildID string, after string, limit int) (st []*Member, err error) {
+// guildID : The ID of a Guild.
+// after : The id of the member to return members after
+// limit : max number of members to return (max 1000)
+func (s *Session) GuildMembers(guildID string, after string, limit int, options ...RequestOption) (st []*Member, err error) {
uri := EndpointGuildMembers(guildID)
@@ -723,7 +800,7 @@ func (s *Session) GuildMembers(guildID string, after string, limit int) (st []*M
uri += "?" + v.Encode()
}
- body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildMembers(guildID))
+ body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildMembers(guildID), options...)
if err != nil {
return
}
@@ -736,7 +813,7 @@ func (s *Session) GuildMembers(guildID string, after string, limit int) (st []*M
// guildID : The ID of a Guild
// query : Query string to match username(s) and nickname(s) against
// limit : Max number of members to return (default 1, min 1, max 1000)
-func (s *Session) GuildMembersSearch(guildID, query string, limit int) (st []*Member, err error) {
+func (s *Session) GuildMembersSearch(guildID, query string, limit int, options ...RequestOption) (st []*Member, err error) {
uri := EndpointGuildMembersSearch(guildID)
@@ -746,7 +823,7 @@ func (s *Session) GuildMembersSearch(guildID, query string, limit int) (st []*Me
queryParams.Set("limit", strconv.Itoa(limit))
}
- body, err := s.RequestWithBucketID("GET", uri+"?"+queryParams.Encode(), nil, uri)
+ body, err := s.RequestWithBucketID("GET", uri+"?"+queryParams.Encode(), nil, uri, options...)
if err != nil {
return
}
@@ -756,11 +833,11 @@ func (s *Session) GuildMembersSearch(guildID, query string, limit int) (st []*Me
}
// GuildMember returns a member of a guild.
-// guildID : The ID of a Guild.
-// userID : The ID of a User
-func (s *Session) GuildMember(guildID, userID string) (st *Member, err error) {
+// guildID : The ID of a Guild.
+// userID : The ID of a User
+func (s *Session) GuildMember(guildID, userID string, options ...RequestOption) (st *Member, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuildMember(guildID, userID), nil, EndpointGuildMember(guildID, ""))
+ body, err := s.RequestWithBucketID("GET", EndpointGuildMember(guildID, userID), nil, EndpointGuildMember(guildID, ""), options...)
if err != nil {
return
}
@@ -772,12 +849,12 @@ func (s *Session) GuildMember(guildID, userID string) (st *Member, err error) {
}
// GuildMemberAdd force joins a user to the guild.
-// guildID : The ID of a Guild.
-// userID : The ID of a User.
-// data : Parameters of the user to add.
-func (s *Session) GuildMemberAdd(guildID, userID string, data *GuildMemberAddParams) (err error) {
+// guildID : The ID of a Guild.
+// userID : The ID of a User.
+// data : Parameters of the user to add.
+func (s *Session) GuildMemberAdd(guildID, userID string, data *GuildMemberAddParams, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("PUT", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
+ _, err = s.RequestWithBucketID("PUT", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""), options...)
if err != nil {
return err
}
@@ -788,23 +865,23 @@ func (s *Session) GuildMemberAdd(guildID, userID string, data *GuildMemberAddPar
// GuildMemberDelete removes the given user from the given guild.
// guildID : The ID of a Guild.
// userID : The ID of a User
-func (s *Session) GuildMemberDelete(guildID, userID string) (err error) {
+func (s *Session) GuildMemberDelete(guildID, userID string, options ...RequestOption) (err error) {
- return s.GuildMemberDeleteWithReason(guildID, userID, "")
+ return s.GuildMemberDeleteWithReason(guildID, userID, "", options...)
}
// GuildMemberDeleteWithReason removes the given user from the given guild.
// guildID : The ID of a Guild.
// userID : The ID of a User
// reason : The reason for the kick
-func (s *Session) GuildMemberDeleteWithReason(guildID, userID, reason string) (err error) {
+func (s *Session) GuildMemberDeleteWithReason(guildID, userID, reason string, options ...RequestOption) (err error) {
uri := EndpointGuildMember(guildID, userID)
if reason != "" {
uri += "?reason=" + url.QueryEscape(reason)
}
- _, err = s.RequestWithBucketID("DELETE", uri, nil, EndpointGuildMember(guildID, ""))
+ _, err = s.RequestWithBucketID("DELETE", uri, nil, EndpointGuildMember(guildID, ""), options...)
return
}
@@ -812,9 +889,9 @@ func (s *Session) GuildMemberDeleteWithReason(guildID, userID, reason string) (e
// guildID : The ID of a Guild.
// userID : The ID of a User.
// data : Updated GuildMember data.
-func (s *Session) GuildMemberEdit(guildID, userID string, data *GuildMemberParams) (st *Member, err error) {
+func (s *Session) GuildMemberEdit(guildID, userID string, data *GuildMemberParams, options ...RequestOption) (st *Member, err error) {
var body []byte
- body, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
+ body, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""), options...)
if err != nil {
return nil, err
}
@@ -825,25 +902,27 @@ func (s *Session) GuildMemberEdit(guildID, userID string, data *GuildMemberParam
// GuildMemberEditComplex edits the nickname and roles of a member.
// NOTE: deprecated, use GuildMemberEdit instead.
+//
// guildID : The ID of a Guild.
// userID : The ID of a User.
// data : A GuildMemberEditData struct with the new nickname and roles
-func (s *Session) GuildMemberEditComplex(guildID, userID string, data *GuildMemberParams) (st *Member, err error) {
- return s.GuildMemberEdit(guildID, userID, data)
+func (s *Session) GuildMemberEditComplex(guildID, userID string, data *GuildMemberParams, options ...RequestOption) (st *Member, err error) {
+ return s.GuildMemberEdit(guildID, userID, data, options...)
}
// GuildMemberMove moves a guild member from one voice channel to another/none
-// guildID : The ID of a Guild.
-// userID : The ID of a User.
-// channelID : The ID of a channel to move user to or nil to remove from voice channel
+// guildID : The ID of a Guild.
+// userID : The ID of a User.
+// channelID : The ID of a channel to move user to or nil to remove from voice channel
+//
// NOTE : I am not entirely set on the name of this function and it may change
// prior to the final 1.0.0 release of Discordgo
-func (s *Session) GuildMemberMove(guildID string, userID string, channelID *string) (err error) {
+func (s *Session) GuildMemberMove(guildID string, userID string, channelID *string, options ...RequestOption) (err error) {
data := struct {
ChannelID *string `json:"channel_id"`
}{channelID}
- _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
+ _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""), options...)
return
}
@@ -852,7 +931,7 @@ func (s *Session) GuildMemberMove(guildID string, userID string, channelID *stri
// userID : The ID of a user
// userID : The ID of a user or "@me" which is a shortcut of the current user ID
// nickname : The nickname of the member, "" will reset their nickname
-func (s *Session) GuildMemberNickname(guildID, userID, nickname string) (err error) {
+func (s *Session) GuildMemberNickname(guildID, userID, nickname string, options ...RequestOption) (err error) {
data := struct {
Nick string `json:"nick"`
@@ -862,68 +941,67 @@ func (s *Session) GuildMemberNickname(guildID, userID, nickname string) (err err
userID += "/nick"
}
- _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
+ _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""), options...)
return
}
// GuildMemberMute server mutes a guild member
-// guildID : The ID of a Guild.
-// userID : The ID of a User.
-// mute : boolean value for if the user should be muted
-func (s *Session) GuildMemberMute(guildID string, userID string, mute bool) (err error) {
+// guildID : The ID of a Guild.
+// userID : The ID of a User.
+// mute : boolean value for if the user should be muted
+func (s *Session) GuildMemberMute(guildID string, userID string, mute bool, options ...RequestOption) (err error) {
data := struct {
Mute bool `json:"mute"`
}{mute}
- _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
+ _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""), options...)
return
}
// GuildMemberTimeout times out a guild member
-// guildID : The ID of a Guild.
-// userID : The ID of a User.
-// until : The timestamp for how long a member should be timed out.
-// Set to nil to remove timeout.
-func (s *Session) GuildMemberTimeout(guildID string, userID string, until *time.Time) (err error) {
+// guildID : The ID of a Guild.
+// userID : The ID of a User.
+// until : The timestamp for how long a member should be timed out. Set to nil to remove timeout.
+func (s *Session) GuildMemberTimeout(guildID string, userID string, until *time.Time, options ...RequestOption) (err error) {
data := struct {
CommunicationDisabledUntil *time.Time `json:"communication_disabled_until"`
}{until}
- _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
+ _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""), options...)
return
}
// GuildMemberDeafen server deafens a guild member
-// guildID : The ID of a Guild.
-// userID : The ID of a User.
-// deaf : boolean value for if the user should be deafened
-func (s *Session) GuildMemberDeafen(guildID string, userID string, deaf bool) (err error) {
+// guildID : The ID of a Guild.
+// userID : The ID of a User.
+// deaf : boolean value for if the user should be deafened
+func (s *Session) GuildMemberDeafen(guildID string, userID string, deaf bool, options ...RequestOption) (err error) {
data := struct {
Deaf bool `json:"deaf"`
}{deaf}
- _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
+ _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""), options...)
return
}
// GuildMemberRoleAdd adds the specified role to a given member
-// guildID : The ID of a Guild.
-// userID : The ID of a User.
-// roleID : The ID of a Role to be assigned to the user.
-func (s *Session) GuildMemberRoleAdd(guildID, userID, roleID string) (err error) {
+// guildID : The ID of a Guild.
+// userID : The ID of a User.
+// roleID : The ID of a Role to be assigned to the user.
+func (s *Session) GuildMemberRoleAdd(guildID, userID, roleID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("PUT", EndpointGuildMemberRole(guildID, userID, roleID), nil, EndpointGuildMemberRole(guildID, "", ""))
+ _, err = s.RequestWithBucketID("PUT", EndpointGuildMemberRole(guildID, userID, roleID), nil, EndpointGuildMemberRole(guildID, "", ""), options...)
return
}
// GuildMemberRoleRemove removes the specified role to a given member
-// guildID : The ID of a Guild.
-// userID : The ID of a User.
-// roleID : The ID of a Role to be removed from the user.
-func (s *Session) GuildMemberRoleRemove(guildID, userID, roleID string) (err error) {
+// guildID : The ID of a Guild.
+// userID : The ID of a User.
+// roleID : The ID of a Role to be removed from the user.
+func (s *Session) GuildMemberRoleRemove(guildID, userID, roleID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointGuildMemberRole(guildID, userID, roleID), nil, EndpointGuildMemberRole(guildID, "", ""))
+ _, err = s.RequestWithBucketID("DELETE", EndpointGuildMemberRole(guildID, userID, roleID), nil, EndpointGuildMemberRole(guildID, "", ""), options...)
return
}
@@ -931,9 +1009,9 @@ func (s *Session) GuildMemberRoleRemove(guildID, userID, roleID string) (err err
// GuildChannels returns an array of Channel structures for all channels of a
// given guild.
// guildID : The ID of a Guild.
-func (s *Session) GuildChannels(guildID string) (st []*Channel, err error) {
+func (s *Session) GuildChannels(guildID string, options ...RequestOption) (st []*Channel, err error) {
- body, err := s.request("GET", EndpointGuildChannels(guildID), "", nil, EndpointGuildChannels(guildID), 0)
+ body, err := s.request("GET", EndpointGuildChannels(guildID), "", nil, EndpointGuildChannels(guildID), 0, options...)
if err != nil {
return
}
@@ -960,8 +1038,8 @@ type GuildChannelCreateData struct {
// GuildChannelCreateComplex creates a new channel in the given guild
// guildID : The ID of a Guild
// data : A data struct describing the new Channel, Name and Type are mandatory, other fields depending on the type
-func (s *Session) GuildChannelCreateComplex(guildID string, data GuildChannelCreateData) (st *Channel, err error) {
- body, err := s.RequestWithBucketID("POST", EndpointGuildChannels(guildID), data, EndpointGuildChannels(guildID))
+func (s *Session) GuildChannelCreateComplex(guildID string, data GuildChannelCreateData, options ...RequestOption) (st *Channel, err error) {
+ body, err := s.RequestWithBucketID("POST", EndpointGuildChannels(guildID), data, EndpointGuildChannels(guildID), options...)
if err != nil {
return
}
@@ -974,17 +1052,17 @@ func (s *Session) GuildChannelCreateComplex(guildID string, data GuildChannelCre
// guildID : The ID of a Guild.
// name : Name of the channel (2-100 chars length)
// ctype : Type of the channel
-func (s *Session) GuildChannelCreate(guildID, name string, ctype ChannelType) (st *Channel, err error) {
+func (s *Session) GuildChannelCreate(guildID, name string, ctype ChannelType, options ...RequestOption) (st *Channel, err error) {
return s.GuildChannelCreateComplex(guildID, GuildChannelCreateData{
Name: name,
Type: ctype,
- })
+ }, options...)
}
// GuildChannelsReorder updates the order of channels in a guild
// guildID : The ID of a Guild.
// channels : Updated channels.
-func (s *Session) GuildChannelsReorder(guildID string, channels []*Channel) (err error) {
+func (s *Session) GuildChannelsReorder(guildID string, channels []*Channel, options ...RequestOption) (err error) {
data := make([]struct {
ID string `json:"id"`
@@ -996,14 +1074,14 @@ func (s *Session) GuildChannelsReorder(guildID string, channels []*Channel) (err
data[i].Position = c.Position
}
- _, err = s.RequestWithBucketID("PATCH", EndpointGuildChannels(guildID), data, EndpointGuildChannels(guildID))
+ _, err = s.RequestWithBucketID("PATCH", EndpointGuildChannels(guildID), data, EndpointGuildChannels(guildID), options...)
return
}
// GuildInvites returns an array of Invite structures for the given guild
// guildID : The ID of a Guild.
-func (s *Session) GuildInvites(guildID string) (st []*Invite, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuildInvites(guildID), nil, EndpointGuildInvites(guildID))
+func (s *Session) GuildInvites(guildID string, options ...RequestOption) (st []*Invite, err error) {
+ body, err := s.RequestWithBucketID("GET", EndpointGuildInvites(guildID), nil, EndpointGuildInvites(guildID), options...)
if err != nil {
return
}
@@ -1014,9 +1092,9 @@ func (s *Session) GuildInvites(guildID string) (st []*Invite, err error) {
// GuildRoles returns all roles for a given guild.
// guildID : The ID of a Guild.
-func (s *Session) GuildRoles(guildID string) (st []*Role, err error) {
+func (s *Session) GuildRoles(guildID string, options ...RequestOption) (st []*Role, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuildRoles(guildID), nil, EndpointGuildRoles(guildID))
+ body, err := s.RequestWithBucketID("GET", EndpointGuildRoles(guildID), nil, EndpointGuildRoles(guildID), options...)
if err != nil {
return
}
@@ -1029,8 +1107,8 @@ func (s *Session) GuildRoles(guildID string) (st []*Role, err error) {
// GuildRoleCreate creates a new Guild Role and returns it.
// guildID : The ID of a Guild.
// data : New Role parameters.
-func (s *Session) GuildRoleCreate(guildID string, data *RoleParams) (st *Role, err error) {
- body, err := s.RequestWithBucketID("POST", EndpointGuildRoles(guildID), data, EndpointGuildRoles(guildID))
+func (s *Session) GuildRoleCreate(guildID string, data *RoleParams, options ...RequestOption) (st *Role, err error) {
+ body, err := s.RequestWithBucketID("POST", EndpointGuildRoles(guildID), data, EndpointGuildRoles(guildID), options...)
if err != nil {
return
}
@@ -1044,14 +1122,14 @@ func (s *Session) GuildRoleCreate(guildID string, data *RoleParams) (st *Role, e
// guildID : The ID of a Guild.
// roleID : The ID of a Role.
// data : Updated Role data.
-func (s *Session) GuildRoleEdit(guildID, roleID string, data *RoleParams) (st *Role, err error) {
+func (s *Session) GuildRoleEdit(guildID, roleID string, data *RoleParams, options ...RequestOption) (st *Role, err error) {
// Prevent sending a color int that is too big.
if data.Color != nil && *data.Color > 0xFFFFFF {
return nil, fmt.Errorf("color value cannot be larger than 0xFFFFFF")
}
- body, err := s.RequestWithBucketID("PATCH", EndpointGuildRole(guildID, roleID), data, EndpointGuildRole(guildID, ""))
+ body, err := s.RequestWithBucketID("PATCH", EndpointGuildRole(guildID, roleID), data, EndpointGuildRole(guildID, ""), options...)
if err != nil {
return
}
@@ -1064,9 +1142,9 @@ func (s *Session) GuildRoleEdit(guildID, roleID string, data *RoleParams) (st *R
// GuildRoleReorder reoders guild roles
// guildID : The ID of a Guild.
// roles : A list of ordered roles.
-func (s *Session) GuildRoleReorder(guildID string, roles []*Role) (st []*Role, err error) {
+func (s *Session) GuildRoleReorder(guildID string, roles []*Role, options ...RequestOption) (st []*Role, err error) {
- body, err := s.RequestWithBucketID("PATCH", EndpointGuildRoles(guildID), roles, EndpointGuildRoles(guildID))
+ body, err := s.RequestWithBucketID("PATCH", EndpointGuildRoles(guildID), roles, EndpointGuildRoles(guildID), options...)
if err != nil {
return
}
@@ -1079,9 +1157,9 @@ func (s *Session) GuildRoleReorder(guildID string, roles []*Role) (st []*Role, e
// GuildRoleDelete deletes an existing role.
// guildID : The ID of a Guild.
// roleID : The ID of a Role.
-func (s *Session) GuildRoleDelete(guildID, roleID string) (err error) {
+func (s *Session) GuildRoleDelete(guildID, roleID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointGuildRole(guildID, roleID), nil, EndpointGuildRole(guildID, ""))
+ _, err = s.RequestWithBucketID("DELETE", EndpointGuildRole(guildID, roleID), nil, EndpointGuildRole(guildID, ""), options...)
return
}
@@ -1090,7 +1168,7 @@ func (s *Session) GuildRoleDelete(guildID, roleID string) (err error) {
// Requires 'KICK_MEMBER' permission.
// guildID : The ID of a Guild.
// days : The number of days to count prune for (1 or more).
-func (s *Session) GuildPruneCount(guildID string, days uint32) (count uint32, err error) {
+func (s *Session) GuildPruneCount(guildID string, days uint32, options ...RequestOption) (count uint32, err error) {
count = 0
if days <= 0 {
@@ -1103,7 +1181,7 @@ func (s *Session) GuildPruneCount(guildID string, days uint32) (count uint32, er
}{}
uri := EndpointGuildPrune(guildID) + "?days=" + strconv.FormatUint(uint64(days), 10)
- body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildPrune(guildID))
+ body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildPrune(guildID), options...)
if err != nil {
return
}
@@ -1122,7 +1200,7 @@ func (s *Session) GuildPruneCount(guildID string, days uint32) (count uint32, er
// Returns an object with one 'pruned' key indicating the number of members that were removed in the prune operation.
// guildID : The ID of a Guild.
// days : The number of days to count prune for (1 or more).
-func (s *Session) GuildPrune(guildID string, days uint32) (count uint32, err error) {
+func (s *Session) GuildPrune(guildID string, days uint32, options ...RequestOption) (count uint32, err error) {
count = 0
@@ -1139,7 +1217,7 @@ func (s *Session) GuildPrune(guildID string, days uint32) (count uint32, err err
Pruned uint32 `json:"pruned"`
}{}
- body, err := s.RequestWithBucketID("POST", EndpointGuildPrune(guildID), data, EndpointGuildPrune(guildID))
+ body, err := s.RequestWithBucketID("POST", EndpointGuildPrune(guildID), data, EndpointGuildPrune(guildID), options...)
if err != nil {
return
}
@@ -1156,9 +1234,9 @@ func (s *Session) GuildPrune(guildID string, days uint32) (count uint32, err err
// GuildIntegrations returns an array of Integrations for a guild.
// guildID : The ID of a Guild.
-func (s *Session) GuildIntegrations(guildID string) (st []*Integration, err error) {
+func (s *Session) GuildIntegrations(guildID string, options ...RequestOption) (st []*Integration, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuildIntegrations(guildID), nil, EndpointGuildIntegrations(guildID))
+ body, err := s.RequestWithBucketID("GET", EndpointGuildIntegrations(guildID), nil, EndpointGuildIntegrations(guildID), options...)
if err != nil {
return
}
@@ -1172,14 +1250,14 @@ func (s *Session) GuildIntegrations(guildID string) (st []*Integration, err erro
// guildID : The ID of a Guild.
// integrationType : The Integration type.
// integrationID : The ID of an integration.
-func (s *Session) GuildIntegrationCreate(guildID, integrationType, integrationID string) (err error) {
+func (s *Session) GuildIntegrationCreate(guildID, integrationType, integrationID string, options ...RequestOption) (err error) {
data := struct {
Type string `json:"type"`
ID string `json:"id"`
}{integrationType, integrationID}
- _, err = s.RequestWithBucketID("POST", EndpointGuildIntegrations(guildID), data, EndpointGuildIntegrations(guildID))
+ _, err = s.RequestWithBucketID("POST", EndpointGuildIntegrations(guildID), data, EndpointGuildIntegrations(guildID), options...)
return
}
@@ -1190,7 +1268,7 @@ func (s *Session) GuildIntegrationCreate(guildID, integrationType, integrationID
// expireBehavior : The behavior when an integration subscription lapses (see the integration object documentation).
// expireGracePeriod : Period (in seconds) where the integration will ignore lapsed subscriptions.
// enableEmoticons : Whether emoticons should be synced for this integration (twitch only currently).
-func (s *Session) GuildIntegrationEdit(guildID, integrationID string, expireBehavior, expireGracePeriod int, enableEmoticons bool) (err error) {
+func (s *Session) GuildIntegrationEdit(guildID, integrationID string, expireBehavior, expireGracePeriod int, enableEmoticons bool, options ...RequestOption) (err error) {
data := struct {
ExpireBehavior int `json:"expire_behavior"`
@@ -1198,23 +1276,23 @@ func (s *Session) GuildIntegrationEdit(guildID, integrationID string, expireBeha
EnableEmoticons bool `json:"enable_emoticons"`
}{expireBehavior, expireGracePeriod, enableEmoticons}
- _, err = s.RequestWithBucketID("PATCH", EndpointGuildIntegration(guildID, integrationID), data, EndpointGuildIntegration(guildID, ""))
+ _, err = s.RequestWithBucketID("PATCH", EndpointGuildIntegration(guildID, integrationID), data, EndpointGuildIntegration(guildID, ""), options...)
return
}
// GuildIntegrationDelete removes the given integration from the Guild.
// guildID : The ID of a Guild.
// integrationID : The ID of an integration.
-func (s *Session) GuildIntegrationDelete(guildID, integrationID string) (err error) {
+func (s *Session) GuildIntegrationDelete(guildID, integrationID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointGuildIntegration(guildID, integrationID), nil, EndpointGuildIntegration(guildID, ""))
+ _, err = s.RequestWithBucketID("DELETE", EndpointGuildIntegration(guildID, integrationID), nil, EndpointGuildIntegration(guildID, ""), options...)
return
}
// GuildIcon returns an image.Image of a guild icon.
// guildID : The ID of a Guild.
-func (s *Session) GuildIcon(guildID string) (img image.Image, err error) {
- g, err := s.Guild(guildID)
+func (s *Session) GuildIcon(guildID string, options ...RequestOption) (img image.Image, err error) {
+ g, err := s.Guild(guildID, options...)
if err != nil {
return
}
@@ -1224,7 +1302,7 @@ func (s *Session) GuildIcon(guildID string) (img image.Image, err error) {
return
}
- body, err := s.RequestWithBucketID("GET", EndpointGuildIcon(guildID, g.Icon), nil, EndpointGuildIcon(guildID, ""))
+ body, err := s.RequestWithBucketID("GET", EndpointGuildIcon(guildID, g.Icon), nil, EndpointGuildIcon(guildID, ""), options...)
if err != nil {
return
}
@@ -1235,8 +1313,8 @@ func (s *Session) GuildIcon(guildID string) (img image.Image, err error) {
// GuildSplash returns an image.Image of a guild splash image.
// guildID : The ID of a Guild.
-func (s *Session) GuildSplash(guildID string) (img image.Image, err error) {
- g, err := s.Guild(guildID)
+func (s *Session) GuildSplash(guildID string, options ...RequestOption) (img image.Image, err error) {
+ g, err := s.Guild(guildID, options...)
if err != nil {
return
}
@@ -1246,7 +1324,7 @@ func (s *Session) GuildSplash(guildID string) (img image.Image, err error) {
return
}
- body, err := s.RequestWithBucketID("GET", EndpointGuildSplash(guildID, g.Splash), nil, EndpointGuildSplash(guildID, ""))
+ body, err := s.RequestWithBucketID("GET", EndpointGuildSplash(guildID, g.Splash), nil, EndpointGuildSplash(guildID, ""), options...)
if err != nil {
return
}
@@ -1257,9 +1335,9 @@ func (s *Session) GuildSplash(guildID string) (img image.Image, err error) {
// GuildEmbed returns the embed for a Guild.
// guildID : The ID of a Guild.
-func (s *Session) GuildEmbed(guildID string) (st *GuildEmbed, err error) {
+func (s *Session) GuildEmbed(guildID string, options ...RequestOption) (st *GuildEmbed, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuildEmbed(guildID), nil, EndpointGuildEmbed(guildID))
+ body, err := s.RequestWithBucketID("GET", EndpointGuildEmbed(guildID), nil, EndpointGuildEmbed(guildID), options...)
if err != nil {
return
}
@@ -1271,8 +1349,8 @@ func (s *Session) GuildEmbed(guildID string) (st *GuildEmbed, err error) {
// GuildEmbedEdit edits the embed of a Guild.
// guildID : The ID of a Guild.
// data : New GuildEmbed data.
-func (s *Session) GuildEmbedEdit(guildID string, data *GuildEmbed) (err error) {
- _, err = s.RequestWithBucketID("PATCH", EndpointGuildEmbed(guildID), data, EndpointGuildEmbed(guildID))
+func (s *Session) GuildEmbedEdit(guildID string, data *GuildEmbed, options ...RequestOption) (err error) {
+ _, err = s.RequestWithBucketID("PATCH", EndpointGuildEmbed(guildID), data, EndpointGuildEmbed(guildID), options...)
return
}
@@ -1282,7 +1360,7 @@ func (s *Session) GuildEmbedEdit(guildID string, data *GuildEmbed) (err error) {
// beforeID : If provided all log entries returned will be before the given ID.
// actionType : If provided the log will be filtered for the given Action Type.
// limit : The number messages that can be returned. (default 50, min 1, max 100)
-func (s *Session) GuildAuditLog(guildID, userID, beforeID string, actionType, limit int) (st *GuildAuditLog, err error) {
+func (s *Session) GuildAuditLog(guildID, userID, beforeID string, actionType, limit int, options ...RequestOption) (st *GuildAuditLog, err error) {
uri := EndpointGuildAuditLogs(guildID)
@@ -1303,7 +1381,7 @@ func (s *Session) GuildAuditLog(guildID, userID, beforeID string, actionType, li
uri = fmt.Sprintf("%s?%s", uri, v.Encode())
}
- body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildAuditLogs(guildID))
+ body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildAuditLogs(guildID), options...)
if err != nil {
return
}
@@ -1314,9 +1392,9 @@ func (s *Session) GuildAuditLog(guildID, userID, beforeID string, actionType, li
// GuildEmojis returns all emoji
// guildID : The ID of a Guild.
-func (s *Session) GuildEmojis(guildID string) (emoji []*Emoji, err error) {
+func (s *Session) GuildEmojis(guildID string, options ...RequestOption) (emoji []*Emoji, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuildEmojis(guildID), nil, EndpointGuildEmojis(guildID))
+ body, err := s.RequestWithBucketID("GET", EndpointGuildEmojis(guildID), nil, EndpointGuildEmojis(guildID), options...)
if err != nil {
return
}
@@ -1328,9 +1406,9 @@ func (s *Session) GuildEmojis(guildID string) (emoji []*Emoji, err error) {
// GuildEmoji returns specified emoji.
// guildID : The ID of a Guild
// emojiID : The ID of an Emoji to retrieve
-func (s *Session) GuildEmoji(guildID, emojiID string) (emoji *Emoji, err error) {
+func (s *Session) GuildEmoji(guildID, emojiID string, options ...RequestOption) (emoji *Emoji, err error) {
var body []byte
- body, err = s.RequestWithBucketID("GET", EndpointGuildEmoji(guildID, emojiID), nil, EndpointGuildEmoji(guildID, emojiID))
+ body, err = s.RequestWithBucketID("GET", EndpointGuildEmoji(guildID, emojiID), nil, EndpointGuildEmoji(guildID, emojiID), options...)
if err != nil {
return
}
@@ -1342,8 +1420,8 @@ func (s *Session) GuildEmoji(guildID, emojiID string) (emoji *Emoji, err error)
// GuildEmojiCreate creates a new Emoji.
// guildID : The ID of a Guild.
// data : New Emoji data.
-func (s *Session) GuildEmojiCreate(guildID string, data *EmojiParams) (emoji *Emoji, err error) {
- body, err := s.RequestWithBucketID("POST", EndpointGuildEmojis(guildID), data, EndpointGuildEmojis(guildID))
+func (s *Session) GuildEmojiCreate(guildID string, data *EmojiParams, options ...RequestOption) (emoji *Emoji, err error) {
+ body, err := s.RequestWithBucketID("POST", EndpointGuildEmojis(guildID), data, EndpointGuildEmojis(guildID), options...)
if err != nil {
return
}
@@ -1356,8 +1434,8 @@ func (s *Session) GuildEmojiCreate(guildID string, data *EmojiParams) (emoji *Em
// guildID : The ID of a Guild.
// emojiID : The ID of an Emoji.
// data : Updated Emoji data.
-func (s *Session) GuildEmojiEdit(guildID, emojiID string, data *EmojiParams) (emoji *Emoji, err error) {
- body, err := s.RequestWithBucketID("PATCH", EndpointGuildEmoji(guildID, emojiID), data, EndpointGuildEmojis(guildID))
+func (s *Session) GuildEmojiEdit(guildID, emojiID string, data *EmojiParams, options ...RequestOption) (emoji *Emoji, err error) {
+ body, err := s.RequestWithBucketID("PATCH", EndpointGuildEmoji(guildID, emojiID), data, EndpointGuildEmojis(guildID), options...)
if err != nil {
return
}
@@ -1369,17 +1447,17 @@ func (s *Session) GuildEmojiEdit(guildID, emojiID string, data *EmojiParams) (em
// GuildEmojiDelete deletes an Emoji.
// guildID : The ID of a Guild.
// emojiID : The ID of an Emoji.
-func (s *Session) GuildEmojiDelete(guildID, emojiID string) (err error) {
+func (s *Session) GuildEmojiDelete(guildID, emojiID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointGuildEmoji(guildID, emojiID), nil, EndpointGuildEmojis(guildID))
+ _, err = s.RequestWithBucketID("DELETE", EndpointGuildEmoji(guildID, emojiID), nil, EndpointGuildEmojis(guildID), options...)
return
}
// GuildTemplate returns a GuildTemplate for the given code
// templateCode: The Code of a GuildTemplate
-func (s *Session) GuildTemplate(templateCode string) (st *GuildTemplate, err error) {
+func (s *Session) GuildTemplate(templateCode string, options ...RequestOption) (st *GuildTemplate, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuildTemplate(templateCode), nil, EndpointGuildTemplate(templateCode))
+ body, err := s.RequestWithBucketID("GET", EndpointGuildTemplate(templateCode), nil, EndpointGuildTemplate(templateCode), options...)
if err != nil {
return
}
@@ -1392,14 +1470,14 @@ func (s *Session) GuildTemplate(templateCode string) (st *GuildTemplate, err err
// templateCode: The Code of a GuildTemplate
// name: The name of the guild (2-100) characters
// icon: base64 encoded 128x128 image for the guild icon
-func (s *Session) GuildCreateWithTemplate(templateCode, name, icon string) (st *Guild, err error) {
+func (s *Session) GuildCreateWithTemplate(templateCode, name, icon string, options ...RequestOption) (st *Guild, err error) {
data := struct {
Name string `json:"name"`
Icon string `json:"icon"`
}{name, icon}
- body, err := s.RequestWithBucketID("POST", EndpointGuildTemplate(templateCode), data, EndpointGuildTemplate(templateCode))
+ body, err := s.RequestWithBucketID("POST", EndpointGuildTemplate(templateCode), data, EndpointGuildTemplate(templateCode), options...)
if err != nil {
return
}
@@ -1410,9 +1488,9 @@ func (s *Session) GuildCreateWithTemplate(templateCode, name, icon string) (st *
// GuildTemplates returns all of GuildTemplates
// guildID: The ID of the guild
-func (s *Session) GuildTemplates(guildID string) (st []*GuildTemplate, err error) {
+func (s *Session) GuildTemplates(guildID string, options ...RequestOption) (st []*GuildTemplate, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuildTemplates(guildID), nil, EndpointGuildTemplates(guildID))
+ body, err := s.RequestWithBucketID("GET", EndpointGuildTemplates(guildID), nil, EndpointGuildTemplates(guildID), options...)
if err != nil {
return
}
@@ -1424,8 +1502,8 @@ func (s *Session) GuildTemplates(guildID string) (st []*GuildTemplate, err error
// GuildTemplateCreate creates a template for the guild
// guildID : The ID of the guild
// data : Template metadata
-func (s *Session) GuildTemplateCreate(guildID string, data *GuildTemplateParams) (st *GuildTemplate) {
- body, err := s.RequestWithBucketID("POST", EndpointGuildTemplates(guildID), data, EndpointGuildTemplates(guildID))
+func (s *Session) GuildTemplateCreate(guildID string, data *GuildTemplateParams, options ...RequestOption) (st *GuildTemplate) {
+ body, err := s.RequestWithBucketID("POST", EndpointGuildTemplates(guildID), data, EndpointGuildTemplates(guildID), options...)
if err != nil {
return
}
@@ -1437,9 +1515,9 @@ func (s *Session) GuildTemplateCreate(guildID string, data *GuildTemplateParams)
// GuildTemplateSync syncs the template to the guild's current state
// guildID: The ID of the guild
// templateCode: The code of the template
-func (s *Session) GuildTemplateSync(guildID, templateCode string) (err error) {
+func (s *Session) GuildTemplateSync(guildID, templateCode string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("PUT", EndpointGuildTemplateSync(guildID, templateCode), nil, EndpointGuildTemplateSync(guildID, ""))
+ _, err = s.RequestWithBucketID("PUT", EndpointGuildTemplateSync(guildID, templateCode), nil, EndpointGuildTemplateSync(guildID, ""), options...)
return
}
@@ -1447,9 +1525,9 @@ func (s *Session) GuildTemplateSync(guildID, templateCode string) (err error) {
// guildID : The ID of the guild
// templateCode : The code of the template
// data : New template metadata
-func (s *Session) GuildTemplateEdit(guildID, templateCode string, data *GuildTemplateParams) (st *GuildTemplate, err error) {
+func (s *Session) GuildTemplateEdit(guildID, templateCode string, data *GuildTemplateParams, options ...RequestOption) (st *GuildTemplate, err error) {
- body, err := s.RequestWithBucketID("PATCH", EndpointGuildTemplateSync(guildID, templateCode), data, EndpointGuildTemplateSync(guildID, ""))
+ body, err := s.RequestWithBucketID("PATCH", EndpointGuildTemplateSync(guildID, templateCode), data, EndpointGuildTemplateSync(guildID, ""), options...)
if err != nil {
return
}
@@ -1461,9 +1539,9 @@ func (s *Session) GuildTemplateEdit(guildID, templateCode string, data *GuildTem
// GuildTemplateDelete deletes the template
// guildID: The ID of the guild
// templateCode: The code of the template
-func (s *Session) GuildTemplateDelete(guildID, templateCode string) (err error) {
+func (s *Session) GuildTemplateDelete(guildID, templateCode string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointGuildTemplateSync(guildID, templateCode), nil, EndpointGuildTemplateSync(guildID, ""))
+ _, err = s.RequestWithBucketID("DELETE", EndpointGuildTemplateSync(guildID, templateCode), nil, EndpointGuildTemplateSync(guildID, ""), options...)
return
}
@@ -1473,8 +1551,8 @@ func (s *Session) GuildTemplateDelete(guildID, templateCode string) (err error)
// Channel returns a Channel structure of a specific Channel.
// channelID : The ID of the Channel you want returned.
-func (s *Session) Channel(channelID string) (st *Channel, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointChannel(channelID), nil, EndpointChannel(channelID))
+func (s *Session) Channel(channelID string, options ...RequestOption) (st *Channel, err error) {
+ body, err := s.RequestWithBucketID("GET", EndpointChannel(channelID), nil, EndpointChannel(channelID), options...)
if err != nil {
return
}
@@ -1486,8 +1564,8 @@ func (s *Session) Channel(channelID string) (st *Channel, err error) {
// ChannelEdit edits the given channel and returns the updated Channel data.
// channelID : The ID of a Channel.
// data : New Channel data.
-func (s *Session) ChannelEdit(channelID string, data *ChannelEdit) (st *Channel, err error) {
- body, err := s.RequestWithBucketID("PATCH", EndpointChannel(channelID), data, EndpointChannel(channelID))
+func (s *Session) ChannelEdit(channelID string, data *ChannelEdit, options ...RequestOption) (st *Channel, err error) {
+ body, err := s.RequestWithBucketID("PATCH", EndpointChannel(channelID), data, EndpointChannel(channelID), options...)
if err != nil {
return
}
@@ -1501,15 +1579,15 @@ func (s *Session) ChannelEdit(channelID string, data *ChannelEdit) (st *Channel,
// NOTE: deprecated, use ChannelEdit instead
// channelID : The ID of a Channel
// data : The channel struct to send
-func (s *Session) ChannelEditComplex(channelID string, data *ChannelEdit) (st *Channel, err error) {
- return s.ChannelEdit(channelID, data)
+func (s *Session) ChannelEditComplex(channelID string, data *ChannelEdit, options ...RequestOption) (st *Channel, err error) {
+ return s.ChannelEdit(channelID, data, options...)
}
// ChannelDelete deletes the given channel
// channelID : The ID of a Channel
-func (s *Session) ChannelDelete(channelID string) (st *Channel, err error) {
+func (s *Session) ChannelDelete(channelID string, options ...RequestOption) (st *Channel, err error) {
- body, err := s.RequestWithBucketID("DELETE", EndpointChannel(channelID), nil, EndpointChannel(channelID))
+ body, err := s.RequestWithBucketID("DELETE", EndpointChannel(channelID), nil, EndpointChannel(channelID), options...)
if err != nil {
return
}
@@ -1521,9 +1599,9 @@ func (s *Session) ChannelDelete(channelID string) (st *Channel, err error) {
// ChannelTyping broadcasts to all members that authenticated user is typing in
// the given channel.
// channelID : The ID of a Channel
-func (s *Session) ChannelTyping(channelID string) (err error) {
+func (s *Session) ChannelTyping(channelID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("POST", EndpointChannelTyping(channelID), nil, EndpointChannelTyping(channelID))
+ _, err = s.RequestWithBucketID("POST", EndpointChannelTyping(channelID), nil, EndpointChannelTyping(channelID), options...)
return
}
@@ -1534,7 +1612,7 @@ func (s *Session) ChannelTyping(channelID string) (err error) {
// beforeID : If provided all messages returned will be before given ID.
// afterID : If provided all messages returned will be after given ID.
// aroundID : If provided all messages returned will be around given ID.
-func (s *Session) ChannelMessages(channelID string, limit int, beforeID, afterID, aroundID string) (st []*Message, err error) {
+func (s *Session) ChannelMessages(channelID string, limit int, beforeID, afterID, aroundID string, options ...RequestOption) (st []*Message, err error) {
uri := EndpointChannelMessages(channelID)
@@ -1555,7 +1633,7 @@ func (s *Session) ChannelMessages(channelID string, limit int, beforeID, afterID
uri += "?" + v.Encode()
}
- body, err := s.RequestWithBucketID("GET", uri, nil, EndpointChannelMessages(channelID))
+ body, err := s.RequestWithBucketID("GET", uri, nil, EndpointChannelMessages(channelID), options...)
if err != nil {
return
}
@@ -1567,9 +1645,9 @@ func (s *Session) ChannelMessages(channelID string, limit int, beforeID, afterID
// ChannelMessage gets a single message by ID from a given channel.
// channeld : The ID of a Channel
// messageID : the ID of a Message
-func (s *Session) ChannelMessage(channelID, messageID string) (st *Message, err error) {
+func (s *Session) ChannelMessage(channelID, messageID string, options ...RequestOption) (st *Message, err error) {
- response, err := s.RequestWithBucketID("GET", EndpointChannelMessage(channelID, messageID), nil, EndpointChannelMessage(channelID, ""))
+ response, err := s.RequestWithBucketID("GET", EndpointChannelMessage(channelID, messageID), nil, EndpointChannelMessage(channelID, ""), options...)
if err != nil {
return
}
@@ -1581,10 +1659,10 @@ func (s *Session) ChannelMessage(channelID, messageID string) (st *Message, err
// ChannelMessageSend sends a message to the given channel.
// channelID : The ID of a Channel.
// content : The message to send.
-func (s *Session) ChannelMessageSend(channelID string, content string) (*Message, error) {
+func (s *Session) ChannelMessageSend(channelID string, content string, options ...RequestOption) (*Message, error) {
return s.ChannelMessageSendComplex(channelID, &MessageSend{
Content: content,
- })
+ }, options...)
}
var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"")
@@ -1592,7 +1670,7 @@ var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"")
// ChannelMessageSendComplex sends a message to the given channel.
// channelID : The ID of a Channel.
// data : The message struct to send.
-func (s *Session) ChannelMessageSendComplex(channelID string, data *MessageSend) (st *Message, err error) {
+func (s *Session) ChannelMessageSendComplex(channelID string, data *MessageSend, options ...RequestOption) (st *Message, err error) {
// TODO: Remove this when compatibility is not required.
if data.Embed != nil {
if data.Embeds == nil {
@@ -1628,9 +1706,9 @@ func (s *Session) ChannelMessageSendComplex(channelID string, data *MessageSend)
return st, encodeErr
}
- response, err = s.request("POST", endpoint, contentType, body, endpoint, 0)
+ response, err = s.request("POST", endpoint, contentType, body, endpoint, 0, options...)
} else {
- response, err = s.RequestWithBucketID("POST", endpoint, data, endpoint)
+ response, err = s.RequestWithBucketID("POST", endpoint, data, endpoint, options...)
}
if err != nil {
return
@@ -1643,63 +1721,63 @@ func (s *Session) ChannelMessageSendComplex(channelID string, data *MessageSend)
// ChannelMessageSendTTS sends a message to the given channel with Text to Speech.
// channelID : The ID of a Channel.
// content : The message to send.
-func (s *Session) ChannelMessageSendTTS(channelID string, content string) (*Message, error) {
+func (s *Session) ChannelMessageSendTTS(channelID string, content string, options ...RequestOption) (*Message, error) {
return s.ChannelMessageSendComplex(channelID, &MessageSend{
Content: content,
TTS: true,
- })
+ }, options...)
}
// ChannelMessageSendEmbed sends a message to the given channel with embedded data.
// channelID : The ID of a Channel.
// embed : The embed data to send.
-func (s *Session) ChannelMessageSendEmbed(channelID string, embed *MessageEmbed) (*Message, error) {
- return s.ChannelMessageSendEmbeds(channelID, []*MessageEmbed{embed})
+func (s *Session) ChannelMessageSendEmbed(channelID string, embed *MessageEmbed, options ...RequestOption) (*Message, error) {
+ return s.ChannelMessageSendEmbeds(channelID, []*MessageEmbed{embed}, options...)
}
// ChannelMessageSendEmbeds sends a message to the given channel with multiple embedded data.
// channelID : The ID of a Channel.
// embeds : The embeds data to send.
-func (s *Session) ChannelMessageSendEmbeds(channelID string, embeds []*MessageEmbed) (*Message, error) {
+func (s *Session) ChannelMessageSendEmbeds(channelID string, embeds []*MessageEmbed, options ...RequestOption) (*Message, error) {
return s.ChannelMessageSendComplex(channelID, &MessageSend{
Embeds: embeds,
- })
+ }, options...)
}
// ChannelMessageSendReply sends a message to the given channel with reference data.
// channelID : The ID of a Channel.
// content : The message to send.
// reference : The message reference to send.
-func (s *Session) ChannelMessageSendReply(channelID string, content string, reference *MessageReference) (*Message, error) {
+func (s *Session) ChannelMessageSendReply(channelID string, content string, reference *MessageReference, options ...RequestOption) (*Message, error) {
if reference == nil {
return nil, fmt.Errorf("reply attempted with nil message reference")
}
return s.ChannelMessageSendComplex(channelID, &MessageSend{
Content: content,
Reference: reference,
- })
+ }, options...)
}
// ChannelMessageSendEmbedReply sends a message to the given channel with reference data and embedded data.
// channelID : The ID of a Channel.
// embed : The embed data to send.
// reference : The message reference to send.
-func (s *Session) ChannelMessageSendEmbedReply(channelID string, embed *MessageEmbed, reference *MessageReference) (*Message, error) {
- return s.ChannelMessageSendEmbedsReply(channelID, []*MessageEmbed{embed}, reference)
+func (s *Session) ChannelMessageSendEmbedReply(channelID string, embed *MessageEmbed, reference *MessageReference, options ...RequestOption) (*Message, error) {
+ return s.ChannelMessageSendEmbedsReply(channelID, []*MessageEmbed{embed}, reference, options...)
}
// ChannelMessageSendEmbedsReply sends a message to the given channel with reference data and multiple embedded data.
// channelID : The ID of a Channel.
// embeds : The embeds data to send.
// reference : The message reference to send.
-func (s *Session) ChannelMessageSendEmbedsReply(channelID string, embeds []*MessageEmbed, reference *MessageReference) (*Message, error) {
+func (s *Session) ChannelMessageSendEmbedsReply(channelID string, embeds []*MessageEmbed, reference *MessageReference, options ...RequestOption) (*Message, error) {
if reference == nil {
return nil, fmt.Errorf("reply attempted with nil message reference")
}
return s.ChannelMessageSendComplex(channelID, &MessageSend{
Embeds: embeds,
Reference: reference,
- })
+ }, options...)
}
// ChannelMessageEdit edits an existing message, replacing it entirely with
@@ -1707,13 +1785,13 @@ func (s *Session) ChannelMessageSendEmbedsReply(channelID string, embeds []*Mess
// channelID : The ID of a Channel
// messageID : The ID of a Message
// content : The contents of the message
-func (s *Session) ChannelMessageEdit(channelID, messageID, content string) (*Message, error) {
- return s.ChannelMessageEditComplex(NewMessageEdit(channelID, messageID).SetContent(content))
+func (s *Session) ChannelMessageEdit(channelID, messageID, content string, options ...RequestOption) (*Message, error) {
+ return s.ChannelMessageEditComplex(NewMessageEdit(channelID, messageID).SetContent(content), options...)
}
// ChannelMessageEditComplex edits an existing message, replacing it entirely with
// the given MessageEdit struct
-func (s *Session) ChannelMessageEditComplex(m *MessageEdit) (st *Message, err error) {
+func (s *Session) ChannelMessageEditComplex(m *MessageEdit, options ...RequestOption) (st *Message, err error) {
// TODO: Remove this when compatibility is not required.
if m.Embed != nil {
if m.Embeds == nil {
@@ -1729,7 +1807,19 @@ func (s *Session) ChannelMessageEditComplex(m *MessageEdit) (st *Message, err er
embed.Type = "rich"
}
}
- response, err := s.RequestWithBucketID("PATCH", EndpointChannelMessage(m.Channel, m.ID), m, EndpointChannelMessage(m.Channel, ""))
+
+ endpoint := EndpointChannelMessage(m.Channel, m.ID)
+
+ var response []byte
+ if len(m.Files) > 0 {
+ contentType, body, encodeErr := MultipartBodyWithJSON(m, m.Files)
+ if encodeErr != nil {
+ return st, encodeErr
+ }
+ response, err = s.request("PATCH", endpoint, contentType, body, EndpointChannelMessage(m.Channel, ""), 0, options...)
+ } else {
+ response, err = s.RequestWithBucketID("PATCH", endpoint, m, EndpointChannelMessage(m.Channel, ""), options...)
+ }
if err != nil {
return
}
@@ -1742,22 +1832,22 @@ func (s *Session) ChannelMessageEditComplex(m *MessageEdit) (st *Message, err er
// channelID : The ID of a Channel
// messageID : The ID of a Message
// embed : The embed data to send
-func (s *Session) ChannelMessageEditEmbed(channelID, messageID string, embed *MessageEmbed) (*Message, error) {
- return s.ChannelMessageEditEmbeds(channelID, messageID, []*MessageEmbed{embed})
+func (s *Session) ChannelMessageEditEmbed(channelID, messageID string, embed *MessageEmbed, options ...RequestOption) (*Message, error) {
+ return s.ChannelMessageEditEmbeds(channelID, messageID, []*MessageEmbed{embed}, options...)
}
// ChannelMessageEditEmbeds edits an existing message with multiple embedded data.
// channelID : The ID of a Channel
// messageID : The ID of a Message
// embeds : The embeds data to send
-func (s *Session) ChannelMessageEditEmbeds(channelID, messageID string, embeds []*MessageEmbed) (*Message, error) {
- return s.ChannelMessageEditComplex(NewMessageEdit(channelID, messageID).SetEmbeds(embeds))
+func (s *Session) ChannelMessageEditEmbeds(channelID, messageID string, embeds []*MessageEmbed, options ...RequestOption) (*Message, error) {
+ return s.ChannelMessageEditComplex(NewMessageEdit(channelID, messageID).SetEmbeds(embeds), options...)
}
// ChannelMessageDelete deletes a message from the Channel.
-func (s *Session) ChannelMessageDelete(channelID, messageID string) (err error) {
+func (s *Session) ChannelMessageDelete(channelID, messageID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointChannelMessage(channelID, messageID), nil, EndpointChannelMessage(channelID, ""))
+ _, err = s.RequestWithBucketID("DELETE", EndpointChannelMessage(channelID, messageID), nil, EndpointChannelMessage(channelID, ""), options...)
return
}
@@ -1766,14 +1856,14 @@ func (s *Session) ChannelMessageDelete(channelID, messageID string) (err error)
// If the slice is empty do nothing.
// channelID : The ID of the channel for the messages to delete.
// messages : The IDs of the messages to be deleted. A slice of string IDs. A maximum of 100 messages.
-func (s *Session) ChannelMessagesBulkDelete(channelID string, messages []string) (err error) {
+func (s *Session) ChannelMessagesBulkDelete(channelID string, messages []string, options ...RequestOption) (err error) {
if len(messages) == 0 {
return
}
if len(messages) == 1 {
- err = s.ChannelMessageDelete(channelID, messages[0])
+ err = s.ChannelMessageDelete(channelID, messages[0], options...)
return
}
@@ -1785,34 +1875,34 @@ func (s *Session) ChannelMessagesBulkDelete(channelID string, messages []string)
Messages []string `json:"messages"`
}{messages}
- _, err = s.RequestWithBucketID("POST", EndpointChannelMessagesBulkDelete(channelID), data, EndpointChannelMessagesBulkDelete(channelID))
+ _, err = s.RequestWithBucketID("POST", EndpointChannelMessagesBulkDelete(channelID), data, EndpointChannelMessagesBulkDelete(channelID), options...)
return
}
// ChannelMessagePin pins a message within a given channel.
// channelID: The ID of a channel.
// messageID: The ID of a message.
-func (s *Session) ChannelMessagePin(channelID, messageID string) (err error) {
+func (s *Session) ChannelMessagePin(channelID, messageID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("PUT", EndpointChannelMessagePin(channelID, messageID), nil, EndpointChannelMessagePin(channelID, ""))
+ _, err = s.RequestWithBucketID("PUT", EndpointChannelMessagePin(channelID, messageID), nil, EndpointChannelMessagePin(channelID, ""), options...)
return
}
// ChannelMessageUnpin unpins a message within a given channel.
// channelID: The ID of a channel.
// messageID: The ID of a message.
-func (s *Session) ChannelMessageUnpin(channelID, messageID string) (err error) {
+func (s *Session) ChannelMessageUnpin(channelID, messageID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointChannelMessagePin(channelID, messageID), nil, EndpointChannelMessagePin(channelID, ""))
+ _, err = s.RequestWithBucketID("DELETE", EndpointChannelMessagePin(channelID, messageID), nil, EndpointChannelMessagePin(channelID, ""), options...)
return
}
// ChannelMessagesPinned returns an array of Message structures for pinned messages
// within a given channel
// channelID : The ID of a Channel.
-func (s *Session) ChannelMessagesPinned(channelID string) (st []*Message, err error) {
+func (s *Session) ChannelMessagesPinned(channelID string, options ...RequestOption) (st []*Message, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointChannelMessagesPins(channelID), nil, EndpointChannelMessagesPins(channelID))
+ body, err := s.RequestWithBucketID("GET", EndpointChannelMessagesPins(channelID), nil, EndpointChannelMessagesPins(channelID), options...)
if err != nil {
return
@@ -1826,8 +1916,8 @@ func (s *Session) ChannelMessagesPinned(channelID string) (st []*Message, err er
// channelID : The ID of a Channel.
// name: The name of the file.
// io.Reader : A reader for the file contents.
-func (s *Session) ChannelFileSend(channelID, name string, r io.Reader) (*Message, error) {
- return s.ChannelMessageSendComplex(channelID, &MessageSend{File: &File{Name: name, Reader: r}})
+func (s *Session) ChannelFileSend(channelID, name string, r io.Reader, options ...RequestOption) (*Message, error) {
+ return s.ChannelMessageSendComplex(channelID, &MessageSend{File: &File{Name: name, Reader: r}}, options...)
}
// ChannelFileSendWithMessage sends a file to the given channel with an message.
@@ -1836,15 +1926,15 @@ func (s *Session) ChannelFileSend(channelID, name string, r io.Reader) (*Message
// content: Optional Message content.
// name: The name of the file.
// io.Reader : A reader for the file contents.
-func (s *Session) ChannelFileSendWithMessage(channelID, content string, name string, r io.Reader) (*Message, error) {
- return s.ChannelMessageSendComplex(channelID, &MessageSend{File: &File{Name: name, Reader: r}, Content: content})
+func (s *Session) ChannelFileSendWithMessage(channelID, content string, name string, r io.Reader, options ...RequestOption) (*Message, error) {
+ return s.ChannelMessageSendComplex(channelID, &MessageSend{File: &File{Name: name, Reader: r}, Content: content}, options...)
}
// ChannelInvites returns an array of Invite structures for the given channel
// channelID : The ID of a Channel
-func (s *Session) ChannelInvites(channelID string) (st []*Invite, err error) {
+func (s *Session) ChannelInvites(channelID string, options ...RequestOption) (st []*Invite, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointChannelInvites(channelID), nil, EndpointChannelInvites(channelID))
+ body, err := s.RequestWithBucketID("GET", EndpointChannelInvites(channelID), nil, EndpointChannelInvites(channelID), options...)
if err != nil {
return
}
@@ -1856,7 +1946,7 @@ func (s *Session) ChannelInvites(channelID string) (st []*Invite, err error) {
// ChannelInviteCreate creates a new invite for the given channel.
// channelID : The ID of a Channel
// i : An Invite struct with the values MaxAge, MaxUses and Temporary defined.
-func (s *Session) ChannelInviteCreate(channelID string, i Invite) (st *Invite, err error) {
+func (s *Session) ChannelInviteCreate(channelID string, i Invite, options ...RequestOption) (st *Invite, err error) {
data := struct {
MaxAge int `json:"max_age"`
@@ -1865,7 +1955,7 @@ func (s *Session) ChannelInviteCreate(channelID string, i Invite) (st *Invite, e
Unique bool `json:"unique"`
}{i.MaxAge, i.MaxUses, i.Temporary, i.Unique}
- body, err := s.RequestWithBucketID("POST", EndpointChannelInvites(channelID), data, EndpointChannelInvites(channelID))
+ body, err := s.RequestWithBucketID("POST", EndpointChannelInvites(channelID), data, EndpointChannelInvites(channelID), options...)
if err != nil {
return
}
@@ -1877,7 +1967,7 @@ func (s *Session) ChannelInviteCreate(channelID string, i Invite) (st *Invite, e
// ChannelPermissionSet creates a Permission Override for the given channel.
// NOTE: This func name may changed. Using Set instead of Create because
// you can both create a new override or update an override with this function.
-func (s *Session) ChannelPermissionSet(channelID, targetID string, targetType PermissionOverwriteType, allow, deny int64) (err error) {
+func (s *Session) ChannelPermissionSet(channelID, targetID string, targetType PermissionOverwriteType, allow, deny int64, options ...RequestOption) (err error) {
data := struct {
ID string `json:"id"`
@@ -1886,15 +1976,15 @@ func (s *Session) ChannelPermissionSet(channelID, targetID string, targetType Pe
Deny int64 `json:"deny,string"`
}{targetID, targetType, allow, deny}
- _, err = s.RequestWithBucketID("PUT", EndpointChannelPermission(channelID, targetID), data, EndpointChannelPermission(channelID, ""))
+ _, err = s.RequestWithBucketID("PUT", EndpointChannelPermission(channelID, targetID), data, EndpointChannelPermission(channelID, ""), options...)
return
}
// ChannelPermissionDelete deletes a specific permission override for the given channel.
// NOTE: Name of this func may change.
-func (s *Session) ChannelPermissionDelete(channelID, targetID string) (err error) {
+func (s *Session) ChannelPermissionDelete(channelID, targetID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointChannelPermission(channelID, targetID), nil, EndpointChannelPermission(channelID, ""))
+ _, err = s.RequestWithBucketID("DELETE", EndpointChannelPermission(channelID, targetID), nil, EndpointChannelPermission(channelID, ""), options...)
return
}
@@ -1902,11 +1992,11 @@ func (s *Session) ChannelPermissionDelete(channelID, targetID string) (err error
// of the channel
// channelID : The ID of a Channel
// messageID : The ID of a Message
-func (s *Session) ChannelMessageCrosspost(channelID, messageID string) (st *Message, err error) {
+func (s *Session) ChannelMessageCrosspost(channelID, messageID string, options ...RequestOption) (st *Message, err error) {
endpoint := EndpointChannelMessageCrosspost(channelID, messageID)
- body, err := s.RequestWithBucketID("POST", endpoint, nil, endpoint)
+ body, err := s.RequestWithBucketID("POST", endpoint, nil, endpoint, options...)
if err != nil {
return
}
@@ -1918,7 +2008,7 @@ func (s *Session) ChannelMessageCrosspost(channelID, messageID string) (st *Mess
// ChannelNewsFollow follows a news channel in the targetID
// channelID : The ID of a News Channel
// targetID : The ID of a Channel where the News Channel should post to
-func (s *Session) ChannelNewsFollow(channelID, targetID string) (st *ChannelFollow, err error) {
+func (s *Session) ChannelNewsFollow(channelID, targetID string, options ...RequestOption) (st *ChannelFollow, err error) {
endpoint := EndpointChannelFollow(channelID)
@@ -1926,7 +2016,7 @@ func (s *Session) ChannelNewsFollow(channelID, targetID string) (st *ChannelFoll
WebhookChannelID string `json:"webhook_channel_id"`
}{targetID}
- body, err := s.RequestWithBucketID("POST", endpoint, data, endpoint)
+ body, err := s.RequestWithBucketID("POST", endpoint, data, endpoint, options...)
if err != nil {
return
}
@@ -1941,9 +2031,9 @@ func (s *Session) ChannelNewsFollow(channelID, targetID string) (st *ChannelFoll
// Invite returns an Invite structure of the given invite
// inviteID : The invite code
-func (s *Session) Invite(inviteID string) (st *Invite, err error) {
+func (s *Session) Invite(inviteID string, options ...RequestOption) (st *Invite, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointInvite(inviteID), nil, EndpointInvite(""))
+ body, err := s.RequestWithBucketID("GET", EndpointInvite(inviteID), nil, EndpointInvite(""), options...)
if err != nil {
return
}
@@ -1954,9 +2044,9 @@ func (s *Session) Invite(inviteID string) (st *Invite, err error) {
// InviteWithCounts returns an Invite structure of the given invite including approximate member counts
// inviteID : The invite code
-func (s *Session) InviteWithCounts(inviteID string) (st *Invite, err error) {
+func (s *Session) InviteWithCounts(inviteID string, options ...RequestOption) (st *Invite, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointInvite(inviteID)+"?with_counts=true", nil, EndpointInvite(""))
+ body, err := s.RequestWithBucketID("GET", EndpointInvite(inviteID)+"?with_counts=true", nil, EndpointInvite(""), options...)
if err != nil {
return
}
@@ -1966,11 +2056,11 @@ func (s *Session) InviteWithCounts(inviteID string) (st *Invite, err error) {
}
// InviteComplex returns an Invite structure of the given invite including specified fields.
-// inviteID : The invite code
-// guildScheduledEventID : If specified, includes specified guild scheduled event.
-// withCounts : Whether to include approximate member counts or not
-// withExpiration : Whether to include expiration time or not
-func (s *Session) InviteComplex(inviteID, guildScheduledEventID string, withCounts, withExpiration bool) (st *Invite, err error) {
+// inviteID : The invite code
+// guildScheduledEventID : If specified, includes specified guild scheduled event.
+// withCounts : Whether to include approximate member counts or not
+// withExpiration : Whether to include expiration time or not
+func (s *Session) InviteComplex(inviteID, guildScheduledEventID string, withCounts, withExpiration bool, options ...RequestOption) (st *Invite, err error) {
endpoint := EndpointInvite(inviteID)
v := url.Values{}
if guildScheduledEventID != "" {
@@ -1987,7 +2077,7 @@ func (s *Session) InviteComplex(inviteID, guildScheduledEventID string, withCoun
endpoint += "?" + v.Encode()
}
- body, err := s.RequestWithBucketID("GET", endpoint, nil, EndpointInvite(""))
+ body, err := s.RequestWithBucketID("GET", endpoint, nil, EndpointInvite(""), options...)
if err != nil {
return
}
@@ -1998,9 +2088,9 @@ func (s *Session) InviteComplex(inviteID, guildScheduledEventID string, withCoun
// InviteDelete deletes an existing invite
// inviteID : the code of an invite
-func (s *Session) InviteDelete(inviteID string) (st *Invite, err error) {
+func (s *Session) InviteDelete(inviteID string, options ...RequestOption) (st *Invite, err error) {
- body, err := s.RequestWithBucketID("DELETE", EndpointInvite(inviteID), nil, EndpointInvite(""))
+ body, err := s.RequestWithBucketID("DELETE", EndpointInvite(inviteID), nil, EndpointInvite(""), options...)
if err != nil {
return
}
@@ -2011,9 +2101,9 @@ func (s *Session) InviteDelete(inviteID string) (st *Invite, err error) {
// InviteAccept accepts an Invite to a Guild or Channel
// inviteID : The invite code
-func (s *Session) InviteAccept(inviteID string) (st *Invite, err error) {
+func (s *Session) InviteAccept(inviteID string, options ...RequestOption) (st *Invite, err error) {
- body, err := s.RequestWithBucketID("POST", EndpointInvite(inviteID), nil, EndpointInvite(""))
+ body, err := s.RequestWithBucketID("POST", EndpointInvite(inviteID), nil, EndpointInvite(""), options...)
if err != nil {
return
}
@@ -2027,9 +2117,9 @@ func (s *Session) InviteAccept(inviteID string) (st *Invite, err error) {
// ------------------------------------------------------------------------------------------------
// VoiceRegions returns the voice server regions
-func (s *Session) VoiceRegions() (st []*VoiceRegion, err error) {
+func (s *Session) VoiceRegions(options ...RequestOption) (st []*VoiceRegion, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointVoiceRegions, nil, EndpointVoiceRegions)
+ body, err := s.RequestWithBucketID("GET", EndpointVoiceRegions, nil, EndpointVoiceRegions, options...)
if err != nil {
return
}
@@ -2043,9 +2133,9 @@ func (s *Session) VoiceRegions() (st []*VoiceRegion, err error) {
// ------------------------------------------------------------------------------------------------
// Gateway returns the websocket Gateway address
-func (s *Session) Gateway() (gateway string, err error) {
+func (s *Session) Gateway(options ...RequestOption) (gateway string, err error) {
- response, err := s.RequestWithBucketID("GET", EndpointGateway, nil, EndpointGateway)
+ response, err := s.RequestWithBucketID("GET", EndpointGateway, nil, EndpointGateway, options...)
if err != nil {
return
}
@@ -2071,9 +2161,9 @@ func (s *Session) Gateway() (gateway string, err error) {
}
// GatewayBot returns the websocket Gateway address and the recommended number of shards
-func (s *Session) GatewayBot() (st *GatewayBotResponse, err error) {
+func (s *Session) GatewayBot(options ...RequestOption) (st *GatewayBotResponse, err error) {
- response, err := s.RequestWithBucketID("GET", EndpointGatewayBot, nil, EndpointGatewayBot)
+ response, err := s.RequestWithBucketID("GET", EndpointGatewayBot, nil, EndpointGatewayBot, options...)
if err != nil {
return
}
@@ -2098,14 +2188,14 @@ func (s *Session) GatewayBot() (st *GatewayBotResponse, err error) {
// channelID: The ID of a Channel.
// name : The name of the webhook.
// avatar : The avatar of the webhook.
-func (s *Session) WebhookCreate(channelID, name, avatar string) (st *Webhook, err error) {
+func (s *Session) WebhookCreate(channelID, name, avatar string, options ...RequestOption) (st *Webhook, err error) {
data := struct {
Name string `json:"name"`
Avatar string `json:"avatar,omitempty"`
}{name, avatar}
- body, err := s.RequestWithBucketID("POST", EndpointChannelWebhooks(channelID), data, EndpointChannelWebhooks(channelID))
+ body, err := s.RequestWithBucketID("POST", EndpointChannelWebhooks(channelID), data, EndpointChannelWebhooks(channelID), options...)
if err != nil {
return
}
@@ -2117,9 +2207,9 @@ func (s *Session) WebhookCreate(channelID, name, avatar string) (st *Webhook, er
// ChannelWebhooks returns all webhooks for a given channel.
// channelID: The ID of a channel.
-func (s *Session) ChannelWebhooks(channelID string) (st []*Webhook, err error) {
+func (s *Session) ChannelWebhooks(channelID string, options ...RequestOption) (st []*Webhook, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointChannelWebhooks(channelID), nil, EndpointChannelWebhooks(channelID))
+ body, err := s.RequestWithBucketID("GET", EndpointChannelWebhooks(channelID), nil, EndpointChannelWebhooks(channelID), options...)
if err != nil {
return
}
@@ -2131,9 +2221,9 @@ func (s *Session) ChannelWebhooks(channelID string) (st []*Webhook, err error) {
// GuildWebhooks returns all webhooks for a given guild.
// guildID: The ID of a Guild.
-func (s *Session) GuildWebhooks(guildID string) (st []*Webhook, err error) {
+func (s *Session) GuildWebhooks(guildID string, options ...RequestOption) (st []*Webhook, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointGuildWebhooks(guildID), nil, EndpointGuildWebhooks(guildID))
+ body, err := s.RequestWithBucketID("GET", EndpointGuildWebhooks(guildID), nil, EndpointGuildWebhooks(guildID), options...)
if err != nil {
return
}
@@ -2145,9 +2235,9 @@ func (s *Session) GuildWebhooks(guildID string) (st []*Webhook, err error) {
// Webhook returns a webhook for a given ID
// webhookID: The ID of a webhook.
-func (s *Session) Webhook(webhookID string) (st *Webhook, err error) {
+func (s *Session) Webhook(webhookID string, options ...RequestOption) (st *Webhook, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointWebhook(webhookID), nil, EndpointWebhooks)
+ body, err := s.RequestWithBucketID("GET", EndpointWebhook(webhookID), nil, EndpointWebhooks, options...)
if err != nil {
return
}
@@ -2160,9 +2250,9 @@ func (s *Session) Webhook(webhookID string) (st *Webhook, err error) {
// WebhookWithToken returns a webhook for a given ID
// webhookID: The ID of a webhook.
// token : The auth token for the webhook.
-func (s *Session) WebhookWithToken(webhookID, token string) (st *Webhook, err error) {
+func (s *Session) WebhookWithToken(webhookID, token string, options ...RequestOption) (st *Webhook, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointWebhookToken(webhookID, token), nil, EndpointWebhookToken("", ""))
+ body, err := s.RequestWithBucketID("GET", EndpointWebhookToken(webhookID, token), nil, EndpointWebhookToken("", ""), options...)
if err != nil {
return
}
@@ -2176,7 +2266,7 @@ func (s *Session) WebhookWithToken(webhookID, token string) (st *Webhook, err er
// 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) (st *Role, err error) {
+func (s *Session) WebhookEdit(webhookID, name, avatar, channelID string, options ...RequestOption) (st *Role, err error) {
data := struct {
Name string `json:"name,omitempty"`
@@ -2184,7 +2274,7 @@ func (s *Session) WebhookEdit(webhookID, name, avatar, channelID string) (st *Ro
ChannelID string `json:"channel_id,omitempty"`
}{name, avatar, channelID}
- body, err := s.RequestWithBucketID("PATCH", EndpointWebhook(webhookID), data, EndpointWebhooks)
+ body, err := s.RequestWithBucketID("PATCH", EndpointWebhook(webhookID), data, EndpointWebhooks, options...)
if err != nil {
return
}
@@ -2199,14 +2289,14 @@ func (s *Session) WebhookEdit(webhookID, name, avatar, channelID string) (st *Ro
// 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) (st *Role, err error) {
+func (s *Session) WebhookEditWithToken(webhookID, token, name, avatar string, options ...RequestOption) (st *Role, 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("", ""))
+ body, err := s.RequestWithBucketID("PATCH", EndpointWebhookToken(webhookID, token), data, EndpointWebhookToken("", ""), options...)
if err != nil {
return
}
@@ -2218,9 +2308,9 @@ func (s *Session) WebhookEditWithToken(webhookID, token, name, avatar string) (s
// WebhookDelete deletes a webhook for a given ID
// webhookID: The ID of a webhook.
-func (s *Session) WebhookDelete(webhookID string) (err error) {
+func (s *Session) WebhookDelete(webhookID string, options ...RequestOption) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointWebhook(webhookID), nil, EndpointWebhooks)
+ _, err = s.RequestWithBucketID("DELETE", EndpointWebhook(webhookID), nil, EndpointWebhooks, options...)
return
}
@@ -2228,9 +2318,9 @@ func (s *Session) WebhookDelete(webhookID string) (err error) {
// WebhookDeleteWithToken deletes a webhook for a given ID with an auth token.
// webhookID: The ID of a webhook.
// token : The auth token for the webhook.
-func (s *Session) WebhookDeleteWithToken(webhookID, token string) (st *Webhook, err error) {
+func (s *Session) WebhookDeleteWithToken(webhookID, token string, options ...RequestOption) (st *Webhook, err error) {
- body, err := s.RequestWithBucketID("DELETE", EndpointWebhookToken(webhookID, token), nil, EndpointWebhookToken("", ""))
+ body, err := s.RequestWithBucketID("DELETE", EndpointWebhookToken(webhookID, token), nil, EndpointWebhookToken("", ""), options...)
if err != nil {
return
}
@@ -2240,7 +2330,7 @@ func (s *Session) WebhookDeleteWithToken(webhookID, token string) (st *Webhook,
return
}
-func (s *Session) webhookExecute(webhookID, token string, wait bool, threadID string, data *WebhookParams) (st *Message, err error) {
+func (s *Session) webhookExecute(webhookID, token string, wait bool, threadID string, data *WebhookParams, options ...RequestOption) (st *Message, err error) {
uri := EndpointWebhookToken(webhookID, token)
v := url.Values{}
@@ -2262,9 +2352,9 @@ func (s *Session) webhookExecute(webhookID, token string, wait bool, threadID st
return st, encodeErr
}
- response, err = s.request("POST", uri, contentType, body, uri, 0)
+ response, err = s.request("POST", uri, contentType, body, uri, 0, options...)
} else {
- response, err = s.RequestWithBucketID("POST", uri, data, uri)
+ response, err = s.RequestWithBucketID("POST", uri, data, uri, options...)
}
if !wait || err != nil {
return
@@ -2278,8 +2368,8 @@ func (s *Session) webhookExecute(webhookID, token string, wait bool, threadID st
// webhookID: The ID of a webhook.
// token : The auth token for the webhook
// wait : Waits for server confirmation of message send and ensures that the return struct is populated (it is nil otherwise)
-func (s *Session) WebhookExecute(webhookID, token string, wait bool, data *WebhookParams) (st *Message, err error) {
- return s.webhookExecute(webhookID, token, wait, "", data)
+func (s *Session) WebhookExecute(webhookID, token string, wait bool, data *WebhookParams, options ...RequestOption) (st *Message, err error) {
+ return s.webhookExecute(webhookID, token, wait, "", data, options...)
}
// WebhookThreadExecute executes a webhook in a thread.
@@ -2287,18 +2377,18 @@ func (s *Session) WebhookExecute(webhookID, token string, wait bool, data *Webho
// token : The auth token for the webhook
// wait : Waits for server confirmation of message send and ensures that the return struct is populated (it is nil otherwise)
// threadID : Sends a message to the specified thread within a webhook's channel. The thread will automatically be unarchived.
-func (s *Session) WebhookThreadExecute(webhookID, token string, wait bool, threadID string, data *WebhookParams) (st *Message, err error) {
- return s.webhookExecute(webhookID, token, wait, threadID, data)
+func (s *Session) WebhookThreadExecute(webhookID, token string, wait bool, threadID string, data *WebhookParams, options ...RequestOption) (st *Message, err error) {
+ return s.webhookExecute(webhookID, token, wait, threadID, data, options...)
}
// WebhookMessage gets a webhook message.
// webhookID : The ID of a webhook
// token : The auth token for the webhook
// messageID : The ID of message to get
-func (s *Session) WebhookMessage(webhookID, token, messageID string) (message *Message, err error) {
+func (s *Session) WebhookMessage(webhookID, token, messageID string, options ...RequestOption) (message *Message, err error) {
uri := EndpointWebhookMessage(webhookID, token, messageID)
- body, err := s.RequestWithBucketID("GET", uri, nil, EndpointWebhookToken("", ""))
+ body, err := s.RequestWithBucketID("GET", uri, nil, EndpointWebhookToken("", ""), options...)
if err != nil {
return
}
@@ -2312,7 +2402,7 @@ func (s *Session) WebhookMessage(webhookID, token, messageID string) (message *M
// webhookID : The ID of a webhook
// token : The auth token for the webhook
// messageID : The ID of message to edit
-func (s *Session) WebhookMessageEdit(webhookID, token, messageID string, data *WebhookEdit) (st *Message, err error) {
+func (s *Session) WebhookMessageEdit(webhookID, token, messageID string, data *WebhookEdit, options ...RequestOption) (st *Message, err error) {
uri := EndpointWebhookMessage(webhookID, token, messageID)
var response []byte
@@ -2322,12 +2412,12 @@ func (s *Session) WebhookMessageEdit(webhookID, token, messageID string, data *W
return nil, err
}
- response, err = s.request("PATCH", uri, contentType, body, uri, 0)
+ response, err = s.request("PATCH", uri, contentType, body, uri, 0, options...)
if err != nil {
return nil, err
}
} else {
- response, err = s.RequestWithBucketID("PATCH", uri, data, EndpointWebhookToken("", ""))
+ response, err = s.RequestWithBucketID("PATCH", uri, data, EndpointWebhookToken("", ""), options...)
if err != nil {
return nil, err
@@ -2342,10 +2432,10 @@ func (s *Session) WebhookMessageEdit(webhookID, token, messageID string, data *W
// webhookID : The ID of a webhook
// token : The auth token for the webhook
// messageID : The ID of a message to edit
-func (s *Session) WebhookMessageDelete(webhookID, token, messageID string) (err error) {
+func (s *Session) WebhookMessageDelete(webhookID, token, messageID string, options ...RequestOption) (err error) {
uri := EndpointWebhookMessage(webhookID, token, messageID)
- _, err = s.RequestWithBucketID("DELETE", uri, nil, EndpointWebhookToken("", ""))
+ _, err = s.RequestWithBucketID("DELETE", uri, nil, EndpointWebhookToken("", ""), options...)
return
}
@@ -2353,11 +2443,11 @@ func (s *Session) WebhookMessageDelete(webhookID, token, messageID string) (err
// channelID : The channel ID.
// messageID : The message ID.
// emojiID : Either the unicode emoji for the reaction, or a guild emoji identifier in name:id format (e.g. "hello:1234567654321")
-func (s *Session) MessageReactionAdd(channelID, messageID, emojiID string) error {
+func (s *Session) MessageReactionAdd(channelID, messageID, emojiID string, options ...RequestOption) error {
// emoji such as #⃣ need to have # escaped
emojiID = strings.Replace(emojiID, "#", "%23", -1)
- _, err := s.RequestWithBucketID("PUT", EndpointMessageReaction(channelID, messageID, emojiID, "@me"), nil, EndpointMessageReaction(channelID, "", "", ""))
+ _, err := s.RequestWithBucketID("PUT", EndpointMessageReaction(channelID, messageID, emojiID, "@me"), nil, EndpointMessageReaction(channelID, "", "", ""), options...)
return err
}
@@ -2367,11 +2457,11 @@ func (s *Session) MessageReactionAdd(channelID, messageID, emojiID string) error
// messageID : The message ID.
// emojiID : Either the unicode emoji for the reaction, or a guild emoji identifier.
// userID : @me or ID of the user to delete the reaction for.
-func (s *Session) MessageReactionRemove(channelID, messageID, emojiID, userID string) error {
+func (s *Session) MessageReactionRemove(channelID, messageID, emojiID, userID string, options ...RequestOption) error {
// emoji such as #⃣ need to have # escaped
emojiID = strings.Replace(emojiID, "#", "%23", -1)
- _, err := s.RequestWithBucketID("DELETE", EndpointMessageReaction(channelID, messageID, emojiID, userID), nil, EndpointMessageReaction(channelID, "", "", ""))
+ _, err := s.RequestWithBucketID("DELETE", EndpointMessageReaction(channelID, messageID, emojiID, userID), nil, EndpointMessageReaction(channelID, "", "", ""), options...)
return err
}
@@ -2379,9 +2469,9 @@ func (s *Session) MessageReactionRemove(channelID, messageID, emojiID, userID st
// MessageReactionsRemoveAll deletes all reactions from a message
// channelID : The channel ID
// messageID : The message ID.
-func (s *Session) MessageReactionsRemoveAll(channelID, messageID string) error {
+func (s *Session) MessageReactionsRemoveAll(channelID, messageID string, options ...RequestOption) error {
- _, err := s.RequestWithBucketID("DELETE", EndpointMessageReactionsAll(channelID, messageID), nil, EndpointMessageReactionsAll(channelID, messageID))
+ _, err := s.RequestWithBucketID("DELETE", EndpointMessageReactionsAll(channelID, messageID), nil, EndpointMessageReactionsAll(channelID, messageID), options...)
return err
}
@@ -2390,11 +2480,11 @@ func (s *Session) MessageReactionsRemoveAll(channelID, messageID string) error {
// channelID : The channel ID
// messageID : The message ID
// emojiID : The emoji ID
-func (s *Session) MessageReactionsRemoveEmoji(channelID, messageID, emojiID string) error {
+func (s *Session) MessageReactionsRemoveEmoji(channelID, messageID, emojiID string, options ...RequestOption) error {
// emoji such as #⃣ need to have # escaped
emojiID = strings.Replace(emojiID, "#", "%23", -1)
- _, err := s.RequestWithBucketID("DELETE", EndpointMessageReactions(channelID, messageID, emojiID), nil, EndpointMessageReactions(channelID, messageID, emojiID))
+ _, err := s.RequestWithBucketID("DELETE", EndpointMessageReactions(channelID, messageID, emojiID), nil, EndpointMessageReactions(channelID, messageID, emojiID), options...)
return err
}
@@ -2406,7 +2496,7 @@ func (s *Session) MessageReactionsRemoveEmoji(channelID, messageID, emojiID stri
// limit : max number of users to return (max 100)
// beforeID : If provided all reactions returned will be before given ID.
// afterID : If provided all reactions returned will be after given ID.
-func (s *Session) MessageReactions(channelID, messageID, emojiID string, limit int, beforeID, afterID string) (st []*User, err error) {
+func (s *Session) MessageReactions(channelID, messageID, emojiID string, limit int, beforeID, afterID string, options ...RequestOption) (st []*User, err error) {
// emoji such as #⃣ need to have # escaped
emojiID = strings.Replace(emojiID, "#", "%23", -1)
uri := EndpointMessageReactions(channelID, messageID, emojiID)
@@ -2428,7 +2518,7 @@ func (s *Session) MessageReactions(channelID, messageID, emojiID string, limit i
uri += "?" + v.Encode()
}
- body, err := s.RequestWithBucketID("GET", uri, nil, EndpointMessageReaction(channelID, "", "", ""))
+ body, err := s.RequestWithBucketID("GET", uri, nil, EndpointMessageReaction(channelID, "", "", ""), options...)
if err != nil {
return
}
@@ -2445,10 +2535,10 @@ func (s *Session) MessageReactions(channelID, messageID, emojiID string, limit i
// channelID : Channel to create thread in
// messageID : Message to start thread from
// data : Parameters of the thread
-func (s *Session) MessageThreadStartComplex(channelID, messageID string, data *ThreadStart) (ch *Channel, err error) {
+func (s *Session) MessageThreadStartComplex(channelID, messageID string, data *ThreadStart, options ...RequestOption) (ch *Channel, err error) {
endpoint := EndpointChannelMessageThread(channelID, messageID)
var body []byte
- body, err = s.RequestWithBucketID("POST", endpoint, data, endpoint)
+ body, err = s.RequestWithBucketID("POST", endpoint, data, endpoint, options...)
if err != nil {
return
}
@@ -2462,20 +2552,20 @@ func (s *Session) MessageThreadStartComplex(channelID, messageID string, data *T
// messageID : Message to start thread from
// name : Name of the thread
// archiveDuration : Auto archive duration (in minutes)
-func (s *Session) MessageThreadStart(channelID, messageID string, name string, archiveDuration int) (ch *Channel, err error) {
+func (s *Session) MessageThreadStart(channelID, messageID string, name string, archiveDuration int, options ...RequestOption) (ch *Channel, err error) {
return s.MessageThreadStartComplex(channelID, messageID, &ThreadStart{
Name: name,
AutoArchiveDuration: archiveDuration,
- })
+ }, options...)
}
// ThreadStartComplex creates a new thread.
// channelID : Channel to create thread in
// data : Parameters of the thread
-func (s *Session) ThreadStartComplex(channelID string, data *ThreadStart) (ch *Channel, err error) {
+func (s *Session) ThreadStartComplex(channelID string, data *ThreadStart, options ...RequestOption) (ch *Channel, err error) {
endpoint := EndpointChannelThreads(channelID)
var body []byte
- body, err = s.RequestWithBucketID("POST", endpoint, data, endpoint)
+ body, err = s.RequestWithBucketID("POST", endpoint, data, endpoint, options...)
if err != nil {
return
}
@@ -2488,47 +2578,141 @@ func (s *Session) ThreadStartComplex(channelID string, data *ThreadStart) (ch *C
// channelID : Channel to create thread in
// name : Name of the thread
// archiveDuration : Auto archive duration (in minutes)
-func (s *Session) ThreadStart(channelID, name string, typ ChannelType, archiveDuration int) (ch *Channel, err error) {
+func (s *Session) ThreadStart(channelID, name string, typ ChannelType, archiveDuration int, options ...RequestOption) (ch *Channel, err error) {
return s.ThreadStartComplex(channelID, &ThreadStart{
Name: name,
Type: typ,
AutoArchiveDuration: archiveDuration,
- })
+ }, options...)
+}
+
+// ForumThreadStartComplex starts a new thread (creates a post) in a forum channel.
+// channelID : Channel to create thread in.
+// threadData : Parameters of the thread.
+// messageData : Parameters of the starting message.
+func (s *Session) ForumThreadStartComplex(channelID string, threadData *ThreadStart, messageData *MessageSend, options ...RequestOption) (th *Channel, err error) {
+ endpoint := EndpointChannelThreads(channelID)
+
+ // TODO: Remove this when compatibility is not required.
+ if messageData.Embed != nil {
+ if messageData.Embeds == nil {
+ messageData.Embeds = []*MessageEmbed{messageData.Embed}
+ } else {
+ err = fmt.Errorf("cannot specify both Embed and Embeds")
+ return
+ }
+ }
+
+ for _, embed := range messageData.Embeds {
+ if embed.Type == "" {
+ embed.Type = "rich"
+ }
+ }
+
+ // TODO: Remove this when compatibility is not required.
+ files := messageData.Files
+ if messageData.File != nil {
+ if files == nil {
+ files = []*File{messageData.File}
+ } else {
+ err = fmt.Errorf("cannot specify both File and Files")
+ return
+ }
+ }
+
+ data := struct {
+ *ThreadStart
+ Message *MessageSend `json:"message"`
+ }{ThreadStart: threadData, Message: messageData}
+
+ var response []byte
+ if len(files) > 0 {
+ contentType, body, encodeErr := MultipartBodyWithJSON(data, files)
+ if encodeErr != nil {
+ return th, encodeErr
+ }
+
+ response, err = s.request("POST", endpoint, contentType, body, endpoint, 0, options...)
+ } else {
+ response, err = s.RequestWithBucketID("POST", endpoint, data, endpoint, options...)
+ }
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(response, &th)
+ return
+}
+
+// ForumThreadStart starts a new thread (post) in a forum channel.
+// channelID : Channel to create thread in.
+// name : Name of the thread.
+// archiveDuration : Auto archive duration.
+// content : Content of the starting message.
+func (s *Session) ForumThreadStart(channelID, name string, archiveDuration int, content string, options ...RequestOption) (th *Channel, err error) {
+ return s.ForumThreadStartComplex(channelID, &ThreadStart{
+ Name: name,
+ AutoArchiveDuration: archiveDuration,
+ }, &MessageSend{Content: content}, options...)
+}
+
+// ForumThreadStartEmbed starts a new thread (post) in a forum channel.
+// channelID : Channel to create thread in.
+// name : Name of the thread.
+// archiveDuration : Auto archive duration.
+// embed : Embed data of the starting message.
+func (s *Session) ForumThreadStartEmbed(channelID, name string, archiveDuration int, embed *MessageEmbed, options ...RequestOption) (th *Channel, err error) {
+ return s.ForumThreadStartComplex(channelID, &ThreadStart{
+ Name: name,
+ AutoArchiveDuration: archiveDuration,
+ }, &MessageSend{Embeds: []*MessageEmbed{embed}}, options...)
+}
+
+// ForumThreadStartEmbeds starts a new thread (post) in a forum channel.
+// channelID : Channel to create thread in.
+// name : Name of the thread.
+// archiveDuration : Auto archive duration.
+// embeds : Embeds data of the starting message.
+func (s *Session) ForumThreadStartEmbeds(channelID, name string, archiveDuration int, embeds []*MessageEmbed, options ...RequestOption) (th *Channel, err error) {
+ return s.ForumThreadStartComplex(channelID, &ThreadStart{
+ Name: name,
+ AutoArchiveDuration: archiveDuration,
+ }, &MessageSend{Embeds: embeds}, options...)
}
// ThreadJoin adds current user to a thread
-func (s *Session) ThreadJoin(id string) error {
+func (s *Session) ThreadJoin(id string, options ...RequestOption) error {
endpoint := EndpointThreadMember(id, "@me")
- _, err := s.RequestWithBucketID("PUT", endpoint, nil, endpoint)
+ _, err := s.RequestWithBucketID("PUT", endpoint, nil, endpoint, options...)
return err
}
// ThreadLeave removes current user to a thread
-func (s *Session) ThreadLeave(id string) error {
+func (s *Session) ThreadLeave(id string, options ...RequestOption) error {
endpoint := EndpointThreadMember(id, "@me")
- _, err := s.RequestWithBucketID("DELETE", endpoint, nil, endpoint)
+ _, err := s.RequestWithBucketID("DELETE", endpoint, nil, endpoint, options...)
return err
}
// ThreadMemberAdd adds another member to a thread
-func (s *Session) ThreadMemberAdd(threadID, memberID string) error {
+func (s *Session) ThreadMemberAdd(threadID, memberID string, options ...RequestOption) error {
endpoint := EndpointThreadMember(threadID, memberID)
- _, err := s.RequestWithBucketID("PUT", endpoint, nil, endpoint)
+ _, err := s.RequestWithBucketID("PUT", endpoint, nil, endpoint, options...)
return err
}
// ThreadMemberRemove removes another member from a thread
-func (s *Session) ThreadMemberRemove(threadID, memberID string) error {
+func (s *Session) ThreadMemberRemove(threadID, memberID string, options ...RequestOption) error {
endpoint := EndpointThreadMember(threadID, memberID)
- _, err := s.RequestWithBucketID("DELETE", endpoint, nil, endpoint)
+ _, err := s.RequestWithBucketID("DELETE", endpoint, nil, endpoint, options...)
return err
}
// ThreadMember returns thread member object for the specified member of a thread
-func (s *Session) ThreadMember(threadID, memberID string) (member *ThreadMember, err error) {
+func (s *Session) ThreadMember(threadID, memberID string, options ...RequestOption) (member *ThreadMember, err error) {
endpoint := EndpointThreadMember(threadID, memberID)
var body []byte
- body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...)
if err != nil {
return
@@ -2539,9 +2723,9 @@ func (s *Session) ThreadMember(threadID, memberID string) (member *ThreadMember,
}
// ThreadMembers returns all members of specified thread.
-func (s *Session) ThreadMembers(threadID string) (members []*ThreadMember, err error) {
+func (s *Session) ThreadMembers(threadID string, options ...RequestOption) (members []*ThreadMember, err error) {
var body []byte
- body, err = s.RequestWithBucketID("GET", EndpointThreadMembers(threadID), nil, EndpointThreadMembers(threadID))
+ body, err = s.RequestWithBucketID("GET", EndpointThreadMembers(threadID), nil, EndpointThreadMembers(threadID), options...)
if err != nil {
return
@@ -2552,9 +2736,9 @@ func (s *Session) ThreadMembers(threadID string) (members []*ThreadMember, err e
}
// ThreadsActive returns all active threads for specified channel.
-func (s *Session) ThreadsActive(channelID string) (threads *ThreadsList, err error) {
+func (s *Session) ThreadsActive(channelID string, options ...RequestOption) (threads *ThreadsList, err error) {
var body []byte
- body, err = s.RequestWithBucketID("GET", EndpointChannelActiveThreads(channelID), nil, EndpointChannelActiveThreads(channelID))
+ body, err = s.RequestWithBucketID("GET", EndpointChannelActiveThreads(channelID), nil, EndpointChannelActiveThreads(channelID), options...)
if err != nil {
return
}
@@ -2564,9 +2748,9 @@ func (s *Session) ThreadsActive(channelID string) (threads *ThreadsList, err err
}
// GuildThreadsActive returns all active threads for specified guild.
-func (s *Session) GuildThreadsActive(guildID string) (threads *ThreadsList, err error) {
+func (s *Session) GuildThreadsActive(guildID string, options ...RequestOption) (threads *ThreadsList, err error) {
var body []byte
- body, err = s.RequestWithBucketID("GET", EndpointGuildActiveThreads(guildID), nil, EndpointGuildActiveThreads(guildID))
+ body, err = s.RequestWithBucketID("GET", EndpointGuildActiveThreads(guildID), nil, EndpointGuildActiveThreads(guildID), options...)
if err != nil {
return
}
@@ -2578,7 +2762,7 @@ func (s *Session) GuildThreadsActive(guildID string) (threads *ThreadsList, err
// ThreadsArchived returns archived threads for specified channel.
// before : If specified returns only threads before the timestamp
// limit : Optional maximum amount of threads to return.
-func (s *Session) ThreadsArchived(channelID string, before *time.Time, limit int) (threads *ThreadsList, err error) {
+func (s *Session) ThreadsArchived(channelID string, before *time.Time, limit int, options ...RequestOption) (threads *ThreadsList, err error) {
endpoint := EndpointChannelPublicArchivedThreads(channelID)
v := url.Values{}
if before != nil {
@@ -2594,7 +2778,7 @@ func (s *Session) ThreadsArchived(channelID string, before *time.Time, limit int
}
var body []byte
- body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...)
if err != nil {
return
}
@@ -2606,7 +2790,7 @@ func (s *Session) ThreadsArchived(channelID string, before *time.Time, limit int
// ThreadsPrivateArchived returns archived private threads for specified channel.
// before : If specified returns only threads before the timestamp
// limit : Optional maximum amount of threads to return.
-func (s *Session) ThreadsPrivateArchived(channelID string, before *time.Time, limit int) (threads *ThreadsList, err error) {
+func (s *Session) ThreadsPrivateArchived(channelID string, before *time.Time, limit int, options ...RequestOption) (threads *ThreadsList, err error) {
endpoint := EndpointChannelPrivateArchivedThreads(channelID)
v := url.Values{}
if before != nil {
@@ -2621,7 +2805,7 @@ func (s *Session) ThreadsPrivateArchived(channelID string, before *time.Time, li
endpoint += "?" + v.Encode()
}
var body []byte
- body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...)
if err != nil {
return
}
@@ -2633,7 +2817,7 @@ func (s *Session) ThreadsPrivateArchived(channelID string, before *time.Time, li
// ThreadsPrivateJoinedArchived returns archived joined private threads for specified channel.
// before : If specified returns only threads before the timestamp
// limit : Optional maximum amount of threads to return.
-func (s *Session) ThreadsPrivateJoinedArchived(channelID string, before *time.Time, limit int) (threads *ThreadsList, err error) {
+func (s *Session) ThreadsPrivateJoinedArchived(channelID string, before *time.Time, limit int, options ...RequestOption) (threads *ThreadsList, err error) {
endpoint := EndpointChannelJoinedPrivateArchivedThreads(channelID)
v := url.Values{}
if before != nil {
@@ -2648,7 +2832,7 @@ func (s *Session) ThreadsPrivateJoinedArchived(channelID string, before *time.Ti
endpoint += "?" + v.Encode()
}
var body []byte
- body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...)
if err != nil {
return
}
@@ -2665,13 +2849,13 @@ func (s *Session) ThreadsPrivateJoinedArchived(channelID string, before *time.Ti
// appID : The application ID.
// guildID : Guild ID to create guild-specific application command. If empty - creates global application command.
// cmd : New application command data.
-func (s *Session) ApplicationCommandCreate(appID string, guildID string, cmd *ApplicationCommand) (ccmd *ApplicationCommand, err error) {
+func (s *Session) ApplicationCommandCreate(appID string, guildID string, cmd *ApplicationCommand, options ...RequestOption) (ccmd *ApplicationCommand, err error) {
endpoint := EndpointApplicationGlobalCommands(appID)
if guildID != "" {
endpoint = EndpointApplicationGuildCommands(appID, guildID)
}
- body, err := s.RequestWithBucketID("POST", endpoint, *cmd, endpoint)
+ body, err := s.RequestWithBucketID("POST", endpoint, *cmd, endpoint, options...)
if err != nil {
return
}
@@ -2686,13 +2870,13 @@ func (s *Session) ApplicationCommandCreate(appID string, guildID string, cmd *Ap
// cmdID : Application command ID to edit.
// guildID : Guild ID to edit guild-specific application command. If empty - edits global application command.
// cmd : Updated application command data.
-func (s *Session) ApplicationCommandEdit(appID, guildID, cmdID string, cmd *ApplicationCommand) (updated *ApplicationCommand, err error) {
+func (s *Session) ApplicationCommandEdit(appID, guildID, cmdID string, cmd *ApplicationCommand, options ...RequestOption) (updated *ApplicationCommand, err error) {
endpoint := EndpointApplicationGlobalCommand(appID, cmdID)
if guildID != "" {
endpoint = EndpointApplicationGuildCommand(appID, guildID, cmdID)
}
- body, err := s.RequestWithBucketID("PATCH", endpoint, *cmd, endpoint)
+ body, err := s.RequestWithBucketID("PATCH", endpoint, *cmd, endpoint, options...)
if err != nil {
return
}
@@ -2705,13 +2889,13 @@ func (s *Session) ApplicationCommandEdit(appID, guildID, cmdID string, cmd *Appl
// ApplicationCommandBulkOverwrite Creates commands overwriting existing commands. Returns a list of commands.
// appID : The application ID.
// commands : The commands to create.
-func (s *Session) ApplicationCommandBulkOverwrite(appID string, guildID string, commands []*ApplicationCommand) (createdCommands []*ApplicationCommand, err error) {
+func (s *Session) ApplicationCommandBulkOverwrite(appID string, guildID string, commands []*ApplicationCommand, options ...RequestOption) (createdCommands []*ApplicationCommand, err error) {
endpoint := EndpointApplicationGlobalCommands(appID)
if guildID != "" {
endpoint = EndpointApplicationGuildCommands(appID, guildID)
}
- body, err := s.RequestWithBucketID("PUT", endpoint, commands, endpoint)
+ body, err := s.RequestWithBucketID("PUT", endpoint, commands, endpoint, options...)
if err != nil {
return
}
@@ -2725,13 +2909,13 @@ func (s *Session) ApplicationCommandBulkOverwrite(appID string, guildID string,
// appID : The application ID.
// cmdID : Application command ID to delete.
// guildID : Guild ID to delete guild-specific application command. If empty - deletes global application command.
-func (s *Session) ApplicationCommandDelete(appID, guildID, cmdID string) error {
+func (s *Session) ApplicationCommandDelete(appID, guildID, cmdID string, options ...RequestOption) error {
endpoint := EndpointApplicationGlobalCommand(appID, cmdID)
if guildID != "" {
endpoint = EndpointApplicationGuildCommand(appID, guildID, cmdID)
}
- _, err := s.RequestWithBucketID("DELETE", endpoint, nil, endpoint)
+ _, err := s.RequestWithBucketID("DELETE", endpoint, nil, endpoint, options...)
return err
}
@@ -2740,13 +2924,13 @@ func (s *Session) ApplicationCommandDelete(appID, guildID, cmdID string) error {
// appID : The application ID.
// cmdID : Application command ID.
// guildID : Guild ID to retrieve guild-specific application command. If empty - retrieves global application command.
-func (s *Session) ApplicationCommand(appID, guildID, cmdID string) (cmd *ApplicationCommand, err error) {
+func (s *Session) ApplicationCommand(appID, guildID, cmdID string, options ...RequestOption) (cmd *ApplicationCommand, err error) {
endpoint := EndpointApplicationGlobalCommand(appID, cmdID)
if guildID != "" {
endpoint = EndpointApplicationGuildCommand(appID, guildID, cmdID)
}
- body, err := s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ body, err := s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...)
if err != nil {
return
}
@@ -2759,13 +2943,13 @@ func (s *Session) ApplicationCommand(appID, guildID, cmdID string) (cmd *Applica
// ApplicationCommands retrieves all commands in application.
// appID : The application ID.
// guildID : Guild ID to retrieve all guild-specific application commands. If empty - retrieves global application commands.
-func (s *Session) ApplicationCommands(appID, guildID string) (cmd []*ApplicationCommand, err error) {
+func (s *Session) ApplicationCommands(appID, guildID string, options ...RequestOption) (cmd []*ApplicationCommand, err error) {
endpoint := EndpointApplicationGlobalCommands(appID)
if guildID != "" {
endpoint = EndpointApplicationGuildCommands(appID, guildID)
}
- body, err := s.RequestWithBucketID("GET", endpoint+"?with_localizations=true", nil, "GET "+endpoint)
+ body, err := s.RequestWithBucketID("GET", endpoint+"?with_localizations=true", nil, "GET "+endpoint, options...)
if err != nil {
return
}
@@ -2778,11 +2962,11 @@ func (s *Session) ApplicationCommands(appID, guildID string) (cmd []*Application
// GuildApplicationCommandsPermissions returns permissions for application commands in a guild.
// appID : The application ID
// guildID : Guild ID to retrieve application commands permissions for.
-func (s *Session) GuildApplicationCommandsPermissions(appID, guildID string) (permissions []*GuildApplicationCommandPermissions, err error) {
+func (s *Session) GuildApplicationCommandsPermissions(appID, guildID string, options ...RequestOption) (permissions []*GuildApplicationCommandPermissions, err error) {
endpoint := EndpointApplicationCommandsGuildPermissions(appID, guildID)
var body []byte
- body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...)
if err != nil {
return
}
@@ -2795,11 +2979,11 @@ func (s *Session) GuildApplicationCommandsPermissions(appID, guildID string) (pe
// appID : The Application ID
// guildID : The guild ID containing the application command
// cmdID : The command ID to retrieve the permissions of
-func (s *Session) ApplicationCommandPermissions(appID, guildID, cmdID string) (permissions *GuildApplicationCommandPermissions, err error) {
+func (s *Session) ApplicationCommandPermissions(appID, guildID, cmdID string, options ...RequestOption) (permissions *GuildApplicationCommandPermissions, err error) {
endpoint := EndpointApplicationCommandPermissions(appID, guildID, cmdID)
var body []byte
- body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...)
if err != nil {
return
}
@@ -2815,10 +2999,10 @@ func (s *Session) ApplicationCommandPermissions(appID, guildID, cmdID string) (p
// permissions : An object containing a list of permissions for the application command
//
// NOTE: Requires OAuth2 token with applications.commands.permissions.update scope
-func (s *Session) ApplicationCommandPermissionsEdit(appID, guildID, cmdID string, permissions *ApplicationCommandPermissionsList) (err error) {
+func (s *Session) ApplicationCommandPermissionsEdit(appID, guildID, cmdID string, permissions *ApplicationCommandPermissionsList, options ...RequestOption) (err error) {
endpoint := EndpointApplicationCommandPermissions(appID, guildID, cmdID)
- _, err = s.RequestWithBucketID("PUT", endpoint, permissions, endpoint)
+ _, err = s.RequestWithBucketID("PUT", endpoint, permissions, endpoint, options...)
return
}
@@ -2828,17 +3012,17 @@ func (s *Session) ApplicationCommandPermissionsEdit(appID, guildID, cmdID string
// permissions : A list of permissions paired with a command ID, guild ID, and application ID per application command
//
// NOTE: This endpoint has been disabled with updates to command permissions (Permissions v2). Please use ApplicationCommandPermissionsEdit instead.
-func (s *Session) ApplicationCommandPermissionsBatchEdit(appID, guildID string, permissions []*GuildApplicationCommandPermissions) (err error) {
+func (s *Session) ApplicationCommandPermissionsBatchEdit(appID, guildID string, permissions []*GuildApplicationCommandPermissions, options ...RequestOption) (err error) {
endpoint := EndpointApplicationCommandsGuildPermissions(appID, guildID)
- _, err = s.RequestWithBucketID("PUT", endpoint, permissions, endpoint)
+ _, err = s.RequestWithBucketID("PUT", endpoint, permissions, endpoint, options...)
return
}
// InteractionRespond creates the response to an interaction.
// interaction : Interaction instance.
// resp : Response message data.
-func (s *Session) InteractionRespond(interaction *Interaction, resp *InteractionResponse) error {
+func (s *Session) InteractionRespond(interaction *Interaction, resp *InteractionResponse, options ...RequestOption) error {
endpoint := EndpointInteractionResponse(interaction.ID, interaction.Token)
if resp.Data != nil && len(resp.Data.Files) > 0 {
@@ -2847,33 +3031,33 @@ func (s *Session) InteractionRespond(interaction *Interaction, resp *Interaction
return err
}
- _, err = s.request("POST", endpoint, contentType, body, endpoint, 0)
+ _, err = s.request("POST", endpoint, contentType, body, endpoint, 0, options...)
return err
}
- _, err := s.RequestWithBucketID("POST", endpoint, *resp, endpoint)
+ _, err := s.RequestWithBucketID("POST", endpoint, *resp, endpoint, options...)
return err
}
// InteractionResponse gets the response to an interaction.
// interaction : Interaction instance.
-func (s *Session) InteractionResponse(interaction *Interaction) (*Message, error) {
- return s.WebhookMessage(interaction.AppID, interaction.Token, "@original")
+func (s *Session) InteractionResponse(interaction *Interaction, options ...RequestOption) (*Message, error) {
+ return s.WebhookMessage(interaction.AppID, interaction.Token, "@original", options...)
}
// InteractionResponseEdit edits the response to an interaction.
// interaction : Interaction instance.
// newresp : Updated response message data.
-func (s *Session) InteractionResponseEdit(interaction *Interaction, newresp *WebhookEdit) (*Message, error) {
- return s.WebhookMessageEdit(interaction.AppID, interaction.Token, "@original", newresp)
+func (s *Session) InteractionResponseEdit(interaction *Interaction, newresp *WebhookEdit, options ...RequestOption) (*Message, error) {
+ return s.WebhookMessageEdit(interaction.AppID, interaction.Token, "@original", newresp, options...)
}
// InteractionResponseDelete deletes the response to an interaction.
// interaction : Interaction instance.
-func (s *Session) InteractionResponseDelete(interaction *Interaction) error {
+func (s *Session) InteractionResponseDelete(interaction *Interaction, options ...RequestOption) error {
endpoint := EndpointInteractionResponseActions(interaction.AppID, interaction.Token)
- _, err := s.RequestWithBucketID("DELETE", endpoint, nil, endpoint)
+ _, err := s.RequestWithBucketID("DELETE", endpoint, nil, endpoint, options...)
return err
}
@@ -2882,23 +3066,23 @@ func (s *Session) InteractionResponseDelete(interaction *Interaction) error {
// interaction : Interaction instance.
// wait : Waits for server confirmation of message send and ensures that the return struct is populated (it is nil otherwise)
// data : Data of the message to send.
-func (s *Session) FollowupMessageCreate(interaction *Interaction, wait bool, data *WebhookParams) (*Message, error) {
- return s.WebhookExecute(interaction.AppID, interaction.Token, wait, data)
+func (s *Session) FollowupMessageCreate(interaction *Interaction, wait bool, data *WebhookParams, options ...RequestOption) (*Message, error) {
+ return s.WebhookExecute(interaction.AppID, interaction.Token, wait, data, options...)
}
// FollowupMessageEdit edits a followup message of an interaction.
// interaction : Interaction instance.
// messageID : The followup message ID.
// data : Data to update the message
-func (s *Session) FollowupMessageEdit(interaction *Interaction, messageID string, data *WebhookEdit) (*Message, error) {
- return s.WebhookMessageEdit(interaction.AppID, interaction.Token, messageID, data)
+func (s *Session) FollowupMessageEdit(interaction *Interaction, messageID string, data *WebhookEdit, options ...RequestOption) (*Message, error) {
+ return s.WebhookMessageEdit(interaction.AppID, interaction.Token, messageID, data, options...)
}
// FollowupMessageDelete deletes a followup message of an interaction.
// interaction : Interaction instance.
// messageID : The followup message ID.
-func (s *Session) FollowupMessageDelete(interaction *Interaction, messageID string) error {
- return s.WebhookMessageDelete(interaction.AppID, interaction.Token, messageID)
+func (s *Session) FollowupMessageDelete(interaction *Interaction, messageID string, options ...RequestOption) error {
+ return s.WebhookMessageDelete(interaction.AppID, interaction.Token, messageID, options...)
}
// ------------------------------------------------------------------------------------------------
@@ -2908,8 +3092,8 @@ func (s *Session) FollowupMessageDelete(interaction *Interaction, messageID stri
// StageInstanceCreate creates and returns a new Stage instance associated to a Stage channel.
// data : Parameters needed to create a stage instance.
// data : The data of the Stage instance to create
-func (s *Session) StageInstanceCreate(data *StageInstanceParams) (si *StageInstance, err error) {
- body, err := s.RequestWithBucketID("POST", EndpointStageInstances, data, EndpointStageInstances)
+func (s *Session) StageInstanceCreate(data *StageInstanceParams, options ...RequestOption) (si *StageInstance, err error) {
+ body, err := s.RequestWithBucketID("POST", EndpointStageInstances, data, EndpointStageInstances, options...)
if err != nil {
return
}
@@ -2920,8 +3104,8 @@ func (s *Session) StageInstanceCreate(data *StageInstanceParams) (si *StageInsta
// StageInstance will retrieve a Stage instance by ID of the Stage channel.
// channelID : The ID of the Stage channel
-func (s *Session) StageInstance(channelID string) (si *StageInstance, err error) {
- body, err := s.RequestWithBucketID("GET", EndpointStageInstance(channelID), nil, EndpointStageInstance(channelID))
+func (s *Session) StageInstance(channelID string, options ...RequestOption) (si *StageInstance, err error) {
+ body, err := s.RequestWithBucketID("GET", EndpointStageInstance(channelID), nil, EndpointStageInstance(channelID), options...)
if err != nil {
return
}
@@ -2933,9 +3117,9 @@ func (s *Session) StageInstance(channelID string) (si *StageInstance, err error)
// StageInstanceEdit will edit a Stage instance by ID of the Stage channel.
// channelID : The ID of the Stage channel
// data : The data to edit the Stage instance
-func (s *Session) StageInstanceEdit(channelID string, data *StageInstanceParams) (si *StageInstance, err error) {
+func (s *Session) StageInstanceEdit(channelID string, data *StageInstanceParams, options ...RequestOption) (si *StageInstance, err error) {
- body, err := s.RequestWithBucketID("PATCH", EndpointStageInstance(channelID), data, EndpointStageInstance(channelID))
+ body, err := s.RequestWithBucketID("PATCH", EndpointStageInstance(channelID), data, EndpointStageInstance(channelID), options...)
if err != nil {
return
}
@@ -2946,8 +3130,8 @@ func (s *Session) StageInstanceEdit(channelID string, data *StageInstanceParams)
// StageInstanceDelete will delete a Stage instance by ID of the Stage channel.
// channelID : The ID of the Stage channel
-func (s *Session) StageInstanceDelete(channelID string) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointStageInstance(channelID), nil, EndpointStageInstance(channelID))
+func (s *Session) StageInstanceDelete(channelID string, options ...RequestOption) (err error) {
+ _, err = s.RequestWithBucketID("DELETE", EndpointStageInstance(channelID), nil, EndpointStageInstance(channelID), options...)
return
}
@@ -2958,13 +3142,13 @@ func (s *Session) StageInstanceDelete(channelID string) (err error) {
// GuildScheduledEvents returns an array of GuildScheduledEvent for a guild
// guildID : The ID of a Guild
// userCount : Whether to include the user count in the response
-func (s *Session) GuildScheduledEvents(guildID string, userCount bool) (st []*GuildScheduledEvent, err error) {
+func (s *Session) GuildScheduledEvents(guildID string, userCount bool, options ...RequestOption) (st []*GuildScheduledEvent, err error) {
uri := EndpointGuildScheduledEvents(guildID)
if userCount {
uri += "?with_user_count=true"
}
- body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildScheduledEvents(guildID))
+ body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildScheduledEvents(guildID), options...)
if err != nil {
return
}
@@ -2977,13 +3161,13 @@ func (s *Session) GuildScheduledEvents(guildID string, userCount bool) (st []*Gu
// guildID : The ID of a Guild
// eventID : The ID of the event
// userCount : Whether to include the user count in the response
-func (s *Session) GuildScheduledEvent(guildID, eventID string, userCount bool) (st *GuildScheduledEvent, err error) {
+func (s *Session) GuildScheduledEvent(guildID, eventID string, userCount bool, options ...RequestOption) (st *GuildScheduledEvent, err error) {
uri := EndpointGuildScheduledEvent(guildID, eventID)
if userCount {
uri += "?with_user_count=true"
}
- body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildScheduledEvent(guildID, eventID))
+ body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildScheduledEvent(guildID, eventID), options...)
if err != nil {
return
}
@@ -2995,8 +3179,8 @@ func (s *Session) GuildScheduledEvent(guildID, eventID string, userCount bool) (
// GuildScheduledEventCreate creates a GuildScheduledEvent for a guild and returns it
// guildID : The ID of a Guild
// eventID : The ID of the event
-func (s *Session) GuildScheduledEventCreate(guildID string, event *GuildScheduledEventParams) (st *GuildScheduledEvent, err error) {
- body, err := s.RequestWithBucketID("POST", EndpointGuildScheduledEvents(guildID), event, EndpointGuildScheduledEvents(guildID))
+func (s *Session) GuildScheduledEventCreate(guildID string, event *GuildScheduledEventParams, options ...RequestOption) (st *GuildScheduledEvent, err error) {
+ body, err := s.RequestWithBucketID("POST", EndpointGuildScheduledEvents(guildID), event, EndpointGuildScheduledEvents(guildID), options...)
if err != nil {
return
}
@@ -3008,8 +3192,8 @@ func (s *Session) GuildScheduledEventCreate(guildID string, event *GuildSchedule
// GuildScheduledEventEdit updates a specific event for a guild and returns it.
// guildID : The ID of a Guild
// eventID : The ID of the event
-func (s *Session) GuildScheduledEventEdit(guildID, eventID string, event *GuildScheduledEventParams) (st *GuildScheduledEvent, err error) {
- body, err := s.RequestWithBucketID("PATCH", EndpointGuildScheduledEvent(guildID, eventID), event, EndpointGuildScheduledEvent(guildID, eventID))
+func (s *Session) GuildScheduledEventEdit(guildID, eventID string, event *GuildScheduledEventParams, options ...RequestOption) (st *GuildScheduledEvent, err error) {
+ body, err := s.RequestWithBucketID("PATCH", EndpointGuildScheduledEvent(guildID, eventID), event, EndpointGuildScheduledEvent(guildID, eventID), options...)
if err != nil {
return
}
@@ -3021,8 +3205,8 @@ func (s *Session) GuildScheduledEventEdit(guildID, eventID string, event *GuildS
// GuildScheduledEventDelete deletes a specific GuildScheduledEvent in a guild
// guildID : The ID of a Guild
// eventID : The ID of the event
-func (s *Session) GuildScheduledEventDelete(guildID, eventID string) (err error) {
- _, err = s.RequestWithBucketID("DELETE", EndpointGuildScheduledEvent(guildID, eventID), nil, EndpointGuildScheduledEvent(guildID, eventID))
+func (s *Session) GuildScheduledEventDelete(guildID, eventID string, options ...RequestOption) (err error) {
+ _, err = s.RequestWithBucketID("DELETE", EndpointGuildScheduledEvent(guildID, eventID), nil, EndpointGuildScheduledEvent(guildID, eventID), options...)
return
}
@@ -3033,7 +3217,7 @@ func (s *Session) GuildScheduledEventDelete(guildID, eventID string) (err error)
// withMember : Whether to include the member object in the response
// beforeID : If is not empty all returned users entries will be before the given ID
// afterID : If is not empty all returned users entries will be after the given ID
-func (s *Session) GuildScheduledEventUsers(guildID, eventID string, limit int, withMember bool, beforeID, afterID string) (st []*GuildScheduledEventUser, err error) {
+func (s *Session) GuildScheduledEventUsers(guildID, eventID string, limit int, withMember bool, beforeID, afterID string, options ...RequestOption) (st []*GuildScheduledEventUser, err error) {
uri := EndpointGuildScheduledEventUsers(guildID, eventID)
queryParams := url.Values{}
@@ -3054,7 +3238,7 @@ func (s *Session) GuildScheduledEventUsers(guildID, eventID string, limit int, w
uri += "?" + queryParams.Encode()
}
- body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildScheduledEventUsers(guildID, eventID))
+ body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildScheduledEventUsers(guildID, eventID), options...)
if err != nil {
return
}
@@ -3069,11 +3253,11 @@ func (s *Session) GuildScheduledEventUsers(guildID, eventID string, limit int, w
// AutoModerationRules returns a list of auto moderation rules.
// guildID : ID of the guild
-func (s *Session) AutoModerationRules(guildID string) (st []*AutoModerationRule, err error) {
+func (s *Session) AutoModerationRules(guildID string, options ...RequestOption) (st []*AutoModerationRule, err error) {
endpoint := EndpointGuildAutoModerationRules(guildID)
var body []byte
- body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...)
if err != nil {
return
}
@@ -3085,11 +3269,11 @@ func (s *Session) AutoModerationRules(guildID string) (st []*AutoModerationRule,
// AutoModerationRule returns an auto moderation rule.
// guildID : ID of the guild
// ruleID : ID of the auto moderation rule
-func (s *Session) AutoModerationRule(guildID, ruleID string) (st *AutoModerationRule, err error) {
+func (s *Session) AutoModerationRule(guildID, ruleID string, options ...RequestOption) (st *AutoModerationRule, err error) {
endpoint := EndpointGuildAutoModerationRule(guildID, ruleID)
var body []byte
- body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint, options...)
if err != nil {
return
}
@@ -3101,11 +3285,11 @@ func (s *Session) AutoModerationRule(guildID, ruleID string) (st *AutoModeration
// AutoModerationRuleCreate creates an auto moderation rule with the given data and returns it.
// guildID : ID of the guild
// rule : Rule data
-func (s *Session) AutoModerationRuleCreate(guildID string, rule *AutoModerationRule) (st *AutoModerationRule, err error) {
+func (s *Session) AutoModerationRuleCreate(guildID string, rule *AutoModerationRule, options ...RequestOption) (st *AutoModerationRule, err error) {
endpoint := EndpointGuildAutoModerationRules(guildID)
var body []byte
- body, err = s.RequestWithBucketID("POST", endpoint, rule, endpoint)
+ body, err = s.RequestWithBucketID("POST", endpoint, rule, endpoint, options...)
if err != nil {
return
}
@@ -3118,11 +3302,11 @@ func (s *Session) AutoModerationRuleCreate(guildID string, rule *AutoModerationR
// guildID : ID of the guild
// ruleID : ID of the auto moderation rule
// rule : New rule data
-func (s *Session) AutoModerationRuleEdit(guildID, ruleID string, rule *AutoModerationRule) (st *AutoModerationRule, err error) {
+func (s *Session) AutoModerationRuleEdit(guildID, ruleID string, rule *AutoModerationRule, options ...RequestOption) (st *AutoModerationRule, err error) {
endpoint := EndpointGuildAutoModerationRule(guildID, ruleID)
var body []byte
- body, err = s.RequestWithBucketID("PATCH", endpoint, rule, endpoint)
+ body, err = s.RequestWithBucketID("PATCH", endpoint, rule, endpoint, options...)
if err != nil {
return
}
@@ -3134,8 +3318,67 @@ func (s *Session) AutoModerationRuleEdit(guildID, ruleID string, rule *AutoModer
// AutoModerationRuleDelete deletes an auto moderation rule.
// guildID : ID of the guild
// ruleID : ID of the auto moderation rule
-func (s *Session) AutoModerationRuleDelete(guildID, ruleID string) (err error) {
+func (s *Session) AutoModerationRuleDelete(guildID, ruleID string, options ...RequestOption) (err error) {
endpoint := EndpointGuildAutoModerationRule(guildID, ruleID)
- _, err = s.RequestWithBucketID("DELETE", endpoint, nil, endpoint)
+ _, err = s.RequestWithBucketID("DELETE", endpoint, nil, endpoint, options...)
+ return
+}
+
+// ApplicationRoleConnectionMetadata returns application role connection metadata.
+// appID : ID of the application
+func (s *Session) ApplicationRoleConnectionMetadata(appID string) (st []*ApplicationRoleConnectionMetadata, err error) {
+ endpoint := EndpointApplicationRoleConnectionMetadata(appID)
+ var body []byte
+ body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+}
+
+// ApplicationRoleConnectionMetadataUpdate updates and returns application role connection metadata.
+// appID : ID of the application
+// metadata : New metadata
+func (s *Session) ApplicationRoleConnectionMetadataUpdate(appID string, metadata []*ApplicationRoleConnectionMetadata) (st []*ApplicationRoleConnectionMetadata, err error) {
+ endpoint := EndpointApplicationRoleConnectionMetadata(appID)
+ var body []byte
+ body, err = s.RequestWithBucketID("PUT", endpoint, metadata, endpoint)
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+}
+
+// UserApplicationRoleConnection returns user role connection to the specified application.
+// appID : ID of the application
+func (s *Session) UserApplicationRoleConnection(appID string) (st *ApplicationRoleConnection, err error) {
+ endpoint := EndpointUserApplicationRoleConnection(appID)
+ var body []byte
+ body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+
+}
+
+// UserApplicationRoleConnectionUpdate updates and returns user role connection to the specified application.
+// appID : ID of the application
+// connection : New ApplicationRoleConnection data
+func (s *Session) UserApplicationRoleConnectionUpdate(appID string, rconn *ApplicationRoleConnection) (st *ApplicationRoleConnection, err error) {
+ endpoint := EndpointUserApplicationRoleConnection(appID)
+ var body []byte
+ body, err = s.RequestWithBucketID("PUT", endpoint, rconn, endpoint)
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
return
}
diff --git a/vendor/github.com/bwmarrin/discordgo/state.go b/vendor/github.com/bwmarrin/discordgo/state.go
index 6404b71d..d0c7b422 100644
--- a/vendor/github.com/bwmarrin/discordgo/state.go
+++ b/vendor/github.com/bwmarrin/discordgo/state.go
@@ -207,6 +207,15 @@ func (s *State) presenceAdd(guildID string, presence *Presence) error {
if presence.Status != "" {
guild.Presences[i].Status = presence.Status
}
+ if presence.ClientStatus.Desktop != "" {
+ guild.Presences[i].ClientStatus.Desktop = presence.ClientStatus.Desktop
+ }
+ if presence.ClientStatus.Mobile != "" {
+ guild.Presences[i].ClientStatus.Mobile = presence.ClientStatus.Mobile
+ }
+ if presence.ClientStatus.Web != "" {
+ guild.Presences[i].ClientStatus.Web = presence.ClientStatus.Web
+ }
//Update the optionally sent user information
//ID Is a mandatory field so you should not need to check if it is empty
@@ -909,9 +918,11 @@ func (s *State) onReady(se *Session, r *Ready) (err error) {
// if state is disabled, store the bare essentials.
if !se.StateEnabled {
ready := Ready{
- Version: r.Version,
- SessionID: r.SessionID,
- User: r.User,
+ Version: r.Version,
+ SessionID: r.SessionID,
+ User: r.User,
+ Shard: r.Shard,
+ Application: r.Application,
}
s.Ready = ready
@@ -981,6 +992,13 @@ func (s *State) OnInterface(se *Session, i interface{}) (err error) {
}
case *GuildMemberUpdate:
if s.TrackMembers {
+ var old *Member
+ old, err = s.Member(t.GuildID, t.User.ID)
+ if err == nil {
+ oldCopy := *old
+ t.BeforeUpdate = &oldCopy
+ }
+
err = s.MemberAdd(t.Member)
}
case *GuildMemberRemove:
@@ -1023,7 +1041,14 @@ func (s *State) OnInterface(se *Session, i interface{}) (err error) {
}
case *GuildEmojisUpdate:
if s.TrackEmojis {
- err = s.EmojisAdd(t.GuildID, t.Emojis)
+ var guild *Guild
+ guild, err = s.Guild(t.GuildID)
+ if err != nil {
+ return err
+ }
+ s.Lock()
+ defer s.Unlock()
+ guild.Emojis = t.Emojis
}
case *ChannelCreate:
if s.TrackChannels {
diff --git a/vendor/github.com/bwmarrin/discordgo/structs.go b/vendor/github.com/bwmarrin/discordgo/structs.go
index 26f507a9..1c29a7e9 100644
--- a/vendor/github.com/bwmarrin/discordgo/structs.go
+++ b/vendor/github.com/bwmarrin/discordgo/structs.go
@@ -17,7 +17,6 @@ import (
"math"
"net/http"
"regexp"
- "strings"
"sync"
"time"
@@ -156,6 +155,38 @@ type Application struct {
Flags int `json:"flags,omitempty"`
}
+// ApplicationRoleConnectionMetadataType represents the type of application role connection metadata.
+type ApplicationRoleConnectionMetadataType int
+
+// Application role connection metadata types.
+const (
+ ApplicationRoleConnectionMetadataIntegerLessThanOrEqual ApplicationRoleConnectionMetadataType = 1
+ ApplicationRoleConnectionMetadataIntegerGreaterThanOrEqual ApplicationRoleConnectionMetadataType = 2
+ ApplicationRoleConnectionMetadataIntegerEqual ApplicationRoleConnectionMetadataType = 3
+ ApplicationRoleConnectionMetadataIntegerNotEqual ApplicationRoleConnectionMetadataType = 4
+ ApplicationRoleConnectionMetadataDatetimeLessThanOrEqual ApplicationRoleConnectionMetadataType = 5
+ ApplicationRoleConnectionMetadataDatetimeGreaterThanOrEqual ApplicationRoleConnectionMetadataType = 6
+ ApplicationRoleConnectionMetadataBooleanEqual ApplicationRoleConnectionMetadataType = 7
+ ApplicationRoleConnectionMetadataBooleanNotEqual ApplicationRoleConnectionMetadataType = 8
+)
+
+// ApplicationRoleConnectionMetadata stores application role connection metadata.
+type ApplicationRoleConnectionMetadata struct {
+ Type ApplicationRoleConnectionMetadataType `json:"type"`
+ Key string `json:"key"`
+ Name string `json:"name"`
+ NameLocalizations map[Locale]string `json:"name_localizations"`
+ Description string `json:"description"`
+ DescriptionLocalizations map[Locale]string `json:"description_localizations"`
+}
+
+// ApplicationRoleConnection represents the role connection that an application has attached to a user.
+type ApplicationRoleConnection struct {
+ PlatformName string `json:"platform_name"`
+ PlatformUsername string `json:"platform_username"`
+ Metadata map[string]string `json:"metadata"`
+}
+
// UserConnection is a Connection returned from the UserConnections endpoint
type UserConnection struct {
ID string `json:"id"`
@@ -254,6 +285,42 @@ const (
ChannelTypeGuildPublicThread ChannelType = 11
ChannelTypeGuildPrivateThread ChannelType = 12
ChannelTypeGuildStageVoice ChannelType = 13
+ ChannelTypeGuildForum ChannelType = 15
+)
+
+// ChannelFlags represent flags of a channel/thread.
+type ChannelFlags int
+
+// Block containing known ChannelFlags values.
+const (
+ // ChannelFlagPinned indicates whether the thread is pinned in the forum channel.
+ // NOTE: forum threads only.
+ ChannelFlagPinned ChannelFlags = 1 << 1
+ // ChannelFlagRequireTag indicates whether a tag is required to be specified when creating a thread.
+ // NOTE: forum channels only.
+ ChannelFlagRequireTag ChannelFlags = 1 << 4
+)
+
+// ForumSortOrderType represents sort order of a forum channel.
+type ForumSortOrderType int
+
+const (
+ // ForumSortOrderLatestActivity sorts posts by activity.
+ ForumSortOrderLatestActivity ForumSortOrderType = 0
+ // ForumSortOrderCreationDate sorts posts by creation time (from most recent to oldest).
+ ForumSortOrderCreationDate ForumSortOrderType = 1
+)
+
+// ForumLayout represents layout of a forum channel.
+type ForumLayout int
+
+const (
+ // ForumLayoutNotSet represents no default layout.
+ ForumLayoutNotSet ForumLayout = 0
+ // ForumLayoutListView displays forum posts as a list.
+ ForumLayoutListView ForumLayout = 1
+ // ForumLayoutGalleryView displays forum posts as a collection of tiles.
+ ForumLayoutGalleryView ForumLayout = 2
)
// A Channel holds all data related to an individual Discord channel.
@@ -332,6 +399,30 @@ type Channel struct {
// All thread members. State channels only.
Members []*ThreadMember `json:"-"`
+
+ // Channel flags.
+ Flags ChannelFlags `json:"flags"`
+
+ // The set of tags that can be used in a forum channel.
+ AvailableTags []ForumTag `json:"available_tags"`
+
+ // The IDs of the set of tags that have been applied to a thread in a forum channel.
+ AppliedTags []string `json:"applied_tags"`
+
+ // Emoji to use as the default reaction to a forum post.
+ DefaultReactionEmoji ForumDefaultReaction `json:"default_reaction_emoji"`
+
+ // The initial RateLimitPerUser to set on newly created threads in a channel.
+ // This field is copied to the thread at creation time and does not live update.
+ DefaultThreadRateLimitPerUser int `json:"default_thread_rate_limit_per_user"`
+
+ // The default sort order type used to order posts in forum channels.
+ // Defaults to null, which indicates a preferred sort order hasn't been set by a channel admin.
+ DefaultSortOrder *ForumSortOrderType `json:"default_sort_order"`
+
+ // The default forum layout view used to display posts in forum channels.
+ // Defaults to ForumLayoutNotSet, which indicates a layout view has not been set by a channel admin.
+ DefaultForumLayout ForumLayout `json:"default_forum_layout"`
}
// Mention returns a string which mentions the channel
@@ -346,15 +437,17 @@ func (c *Channel) IsThread() bool {
// A ChannelEdit holds Channel Field data for a channel edit.
type ChannelEdit struct {
- Name string `json:"name,omitempty"`
- Topic string `json:"topic,omitempty"`
- NSFW *bool `json:"nsfw,omitempty"`
- Position int `json:"position"`
- Bitrate int `json:"bitrate,omitempty"`
- UserLimit int `json:"user_limit,omitempty"`
- PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
- ParentID string `json:"parent_id,omitempty"`
- RateLimitPerUser *int `json:"rate_limit_per_user,omitempty"`
+ Name string `json:"name,omitempty"`
+ Topic string `json:"topic,omitempty"`
+ NSFW *bool `json:"nsfw,omitempty"`
+ Position int `json:"position"`
+ Bitrate int `json:"bitrate,omitempty"`
+ UserLimit int `json:"user_limit,omitempty"`
+ PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
+ ParentID string `json:"parent_id,omitempty"`
+ RateLimitPerUser *int `json:"rate_limit_per_user,omitempty"`
+ Flags *ChannelFlags `json:"flags,omitempty"`
+ DefaultThreadRateLimitPerUser *int `json:"default_thread_rate_limit_per_user,omitempty"`
// NOTE: threads only
@@ -362,6 +455,16 @@ type ChannelEdit struct {
AutoArchiveDuration int `json:"auto_archive_duration,omitempty"`
Locked *bool `json:"locked,omitempty"`
Invitable *bool `json:"invitable,omitempty"`
+
+ // NOTE: forum channels only
+
+ AvailableTags *[]ForumTag `json:"available_tags,omitempty"`
+ DefaultReactionEmoji *ForumDefaultReaction `json:"default_reaction_emoji,omitempty"`
+ DefaultSortOrder *ForumSortOrderType `json:"default_sort_order,omitempty"` // TODO: null
+ DefaultForumLayout *ForumLayout `json:"default_forum_layout,omitempty"`
+
+ // NOTE: forum threads only
+ AppliedTags *[]string `json:"applied_tags,omitempty"`
}
// A ChannelFollow holds data returned after following a news channel
@@ -395,6 +498,9 @@ type ThreadStart struct {
Type ChannelType `json:"type,omitempty"`
Invitable bool `json:"invitable"`
RateLimitPerUser int `json:"rate_limit_per_user,omitempty"`
+
+ // NOTE: forum threads only
+ AppliedTags []string `json:"applied_tags,omitempty"`
}
// ThreadMetadata contains a number of thread-specific channel fields that are not needed by other channel types.
@@ -438,6 +544,24 @@ type AddedThreadMember struct {
Presence *Presence `json:"presence"`
}
+// ForumDefaultReaction specifies emoji to use as the default reaction to a forum post.
+// NOTE: Exactly one of EmojiID and EmojiName must be set.
+type ForumDefaultReaction struct {
+ // The id of a guild's custom emoji.
+ EmojiID string `json:"emoji_id,omitempty"`
+ // The unicode character of the emoji.
+ EmojiName string `json:"emoji_name,omitempty"`
+}
+
+// ForumTag represents a tag that is able to be applied to a thread in a forum channel.
+type ForumTag struct {
+ ID string `json:"id,omitempty"`
+ Name string `json:"name"`
+ Moderated bool `json:"moderated"`
+ EmojiID string `json:"emoji_id,omitempty"`
+ EmojiName string `json:"emoji_name,omitempty"`
+}
+
// Emoji struct holds data related to Emoji's
type Emoji struct {
ID string `json:"id"`
@@ -452,7 +576,7 @@ type Emoji struct {
// EmojiRegex is the regex used to find and identify emojis in messages
var (
- EmojiRegex = regexp.MustCompile(`<(a|):[A-z0-9_~]+:[0-9]{18}>`)
+ EmojiRegex = regexp.MustCompile(`<(a|):[A-z0-9_~]+:[0-9]{18,20}>`)
)
// MessageFormat returns a correctly formatted Emoji for use in Message content and embeds
@@ -792,16 +916,11 @@ type GuildPreview struct {
}
// IconURL returns a URL to the guild's icon.
-func (g *GuildPreview) IconURL() string {
- if g.Icon == "" {
- return ""
- }
-
- if strings.HasPrefix(g.Icon, "a_") {
- return EndpointGuildIconAnimated(g.ID, g.Icon)
- }
-
- return EndpointGuildIcon(g.ID, g.Icon)
+//
+// size: The size of the desired icon image as a power of two
+// Image size can be any power of two between 16 and 4096.
+func (g *GuildPreview) IconURL(size string) string {
+ return iconURL(g.Icon, EndpointGuildIcon(g.ID, g.Icon), EndpointGuildIconAnimated(g.ID, g.Icon), size)
}
// GuildScheduledEvent is a representation of a scheduled event in a guild. Only for retrieval of the data.
@@ -917,13 +1036,13 @@ type GuildScheduledEventStatus int
const (
// GuildScheduledEventStatusScheduled represents the current event is in scheduled state
- GuildScheduledEventStatusScheduled = 1
+ GuildScheduledEventStatusScheduled GuildScheduledEventStatus = 1
// GuildScheduledEventStatusActive represents the current event is in active state
- GuildScheduledEventStatusActive = 2
+ GuildScheduledEventStatusActive GuildScheduledEventStatus = 2
// GuildScheduledEventStatusCompleted represents the current event is in completed state
- GuildScheduledEventStatusCompleted = 3
+ GuildScheduledEventStatusCompleted GuildScheduledEventStatus = 3
// GuildScheduledEventStatusCanceled represents the current event is in canceled state
- GuildScheduledEventStatusCanceled = 4
+ GuildScheduledEventStatusCanceled GuildScheduledEventStatus = 4
)
// GuildScheduledEventEntityType is the type of entity associated with a guild scheduled event.
@@ -932,11 +1051,11 @@ type GuildScheduledEventEntityType int
const (
// GuildScheduledEventEntityTypeStageInstance represents a stage channel
- GuildScheduledEventEntityTypeStageInstance = 1
+ GuildScheduledEventEntityTypeStageInstance GuildScheduledEventEntityType = 1
// GuildScheduledEventEntityTypeVoice represents a voice channel
- GuildScheduledEventEntityTypeVoice = 2
+ GuildScheduledEventEntityTypeVoice GuildScheduledEventEntityType = 2
// GuildScheduledEventEntityTypeExternal represents an external event
- GuildScheduledEventEntityTypeExternal = 3
+ GuildScheduledEventEntityTypeExternal GuildScheduledEventEntityType = 3
)
// GuildScheduledEventUser is a user subscribed to a scheduled event.
@@ -1007,29 +1126,26 @@ type SystemChannelFlag int
// Block containing known SystemChannelFlag values
const (
- SystemChannelFlagsSuppressJoin SystemChannelFlag = 1 << 0
- SystemChannelFlagsSuppressPremium SystemChannelFlag = 1 << 1
+ SystemChannelFlagsSuppressJoinNotifications SystemChannelFlag = 1 << 0
+ SystemChannelFlagsSuppressPremium SystemChannelFlag = 1 << 1
+ SystemChannelFlagsSuppressGuildReminderNotifications SystemChannelFlag = 1 << 2
+ SystemChannelFlagsSuppressJoinNotificationReplies SystemChannelFlag = 1 << 3
)
// IconURL returns a URL to the guild's icon.
-func (g *Guild) IconURL() string {
- if g.Icon == "" {
- return ""
- }
-
- if strings.HasPrefix(g.Icon, "a_") {
- return EndpointGuildIconAnimated(g.ID, g.Icon)
- }
-
- return EndpointGuildIcon(g.ID, g.Icon)
+//
+// size: The size of the desired icon image as a power of two
+// Image size can be any power of two between 16 and 4096.
+func (g *Guild) IconURL(size string) string {
+ return iconURL(g.Icon, EndpointGuildIcon(g.ID, g.Icon), EndpointGuildIconAnimated(g.ID, g.Icon), size)
}
// BannerURL returns a URL to the guild's banner.
-func (g *Guild) BannerURL() string {
- if g.Banner == "" {
- return ""
- }
- return EndpointGuildBanner(g.ID, g.Banner)
+//
+// size: The size of the desired banner image as a power of two
+// Image size can be any power of two between 16 and 4096.
+func (g *Guild) BannerURL(size string) string {
+ return bannerURL(g.Banner, EndpointGuildBanner(g.ID, g.Banner), EndpointGuildBannerAnimated(g.ID, g.Banner), size)
}
// A UserGuild holds a brief version of a Guild
@@ -1076,12 +1192,22 @@ type GuildParams struct {
Region string `json:"region,omitempty"`
VerificationLevel *VerificationLevel `json:"verification_level,omitempty"`
DefaultMessageNotifications int `json:"default_message_notifications,omitempty"` // TODO: Separate type?
+ ExplicitContentFilter int `json:"explicit_content_filter,omitempty"`
AfkChannelID string `json:"afk_channel_id,omitempty"`
AfkTimeout int `json:"afk_timeout,omitempty"`
Icon string `json:"icon,omitempty"`
OwnerID string `json:"owner_id,omitempty"`
Splash string `json:"splash,omitempty"`
+ DiscoverySplash string `json:"discovery_splash,omitempty"`
Banner string `json:"banner,omitempty"`
+ SystemChannelID string `json:"system_channel_id,omitempty"`
+ SystemChannelFlags SystemChannelFlag `json:"system_channel_flags,omitempty"`
+ RulesChannelID string `json:"rules_channel_id,omitempty"`
+ PublicUpdatesChannelID string `json:"public_updates_channel_id,omitempty"`
+ PreferredLocale Locale `json:"preferred_locale,omitempty"`
+ Features []GuildFeature `json:"features,omitempty"`
+ Description string `json:"description,omitempty"`
+ PremiumProgressBarEnabled *bool `json:"premium_progress_bar_enabled,omitempty"`
}
// A Role stores information about Discord guild member roles.
@@ -1167,10 +1293,11 @@ type VoiceState struct {
// A Presence stores the online, offline, or idle and game status of Guild members.
type Presence struct {
- User *User `json:"user"`
- Status Status `json:"status"`
- Activities []*Activity `json:"activities"`
- Since *int `json:"since"`
+ User *User `json:"user"`
+ Status Status `json:"status"`
+ Activities []*Activity `json:"activities"`
+ Since *int `json:"since"`
+ ClientStatus ClientStatus `json:"client_status"`
}
// A TimeStamps struct contains start and end times used in the rich presence "playing .." Game
@@ -1249,9 +1376,10 @@ func (m *Member) Mention() string {
}
// AvatarURL returns the URL of the member's avatar
-// size: The size of the user's avatar as a power of two
-// if size is an empty string, no size parameter will
-// be added to the URL.
+//
+// size: The size of the user's avatar as a power of two
+// if size is an empty string, no size parameter will
+// be added to the URL.
func (m *Member) AvatarURL(size string) string {
if m.Avatar == "" {
return m.User.AvatarURL(size)
@@ -1262,6 +1390,13 @@ func (m *Member) AvatarURL(size string) string {
}
+// ClientStatus stores the online, offline, idle, or dnd status of each device of a Guild member.
+type ClientStatus struct {
+ Desktop Status `json:"desktop"`
+ Mobile Status `json:"mobile"`
+ Web Status `json:"web"`
+}
+
// Status type definition
type Status string
@@ -1371,9 +1506,21 @@ type AutoModerationTriggerMetadata struct {
// Substrings which will be searched for in content.
// NOTE: should be only used with keyword trigger type.
KeywordFilter []string `json:"keyword_filter,omitempty"`
+ // Regular expression patterns which will be matched against content (maximum of 10).
+ // NOTE: should be only used with keyword trigger type.
+ RegexPatterns []string `json:"regex_patterns,omitempty"`
+
// Internally pre-defined wordsets which will be searched for in content.
// NOTE: should be only used with keyword preset trigger type.
Presets []AutoModerationKeywordPreset `json:"presets,omitempty"`
+
+ // Substrings which should not trigger the rule.
+ // NOTE: should be only used with keyword or keyword preset trigger type.
+ AllowList *[]string `json:"allow_list,omitempty"`
+
+ // Total number of unique role and user mentions allowed per message.
+ // NOTE: should be only used with mention spam trigger type.
+ MentionTotalLimit int `json:"mention_total_limit,omitempty"`
}
// AutoModerationActionType represents an action which will execute whenever a rule is triggered.
@@ -2074,6 +2221,7 @@ const (
ErrCodeUnknownGuildWelcomeScreen = 10069
ErrCodeUnknownGuildScheduledEvent = 10070
ErrCodeUnknownGuildScheduledEventUser = 10071
+ ErrUnknownTag = 10087
ErrCodeBotsCannotUseEndpoint = 20001
ErrCodeOnlyBotsCanUseEndpoint = 20002
@@ -2087,28 +2235,30 @@ const (
ErrCodeStageTopicContainsNotAllowedWordsForPublicStages = 20031
ErrCodeGuildPremiumSubscriptionLevelTooLow = 20035
- ErrCodeMaximumGuildsReached = 30001
- ErrCodeMaximumPinsReached = 30003
- ErrCodeMaximumNumberOfRecipientsReached = 30004
- ErrCodeMaximumGuildRolesReached = 30005
- ErrCodeMaximumNumberOfWebhooksReached = 30007
- ErrCodeMaximumNumberOfEmojisReached = 30008
- ErrCodeTooManyReactions = 30010
- ErrCodeMaximumNumberOfGuildChannelsReached = 30013
- ErrCodeMaximumNumberOfAttachmentsInAMessageReached = 30015
- ErrCodeMaximumNumberOfInvitesReached = 30016
- ErrCodeMaximumNumberOfAnimatedEmojisReached = 30018
- ErrCodeMaximumNumberOfServerMembersReached = 30019
- ErrCodeMaximumNumberOfGuildDiscoverySubcategoriesReached = 30030
- ErrCodeGuildAlreadyHasATemplate = 30031
- ErrCodeMaximumNumberOfThreadParticipantsReached = 30033
- ErrCodeMaximumNumberOfBansForNonGuildMembersHaveBeenExceeded = 30035
- ErrCodeMaximumNumberOfBansFetchesHasBeenReached = 30037
- ErrCodeMaximumNumberOfUncompletedGuildScheduledEventsReached = 30038
- ErrCodeMaximumNumberOfStickersReached = 30039
- ErrCodeMaximumNumberOfPruneRequestsHasBeenReached = 30040
- ErrCodeMaximumNumberOfGuildWidgetSettingsUpdatesHasBeenReached = 30042
- ErrCodeMaximumNumberOfEditsToMessagesOlderThanOneHourReached = 30046
+ ErrCodeMaximumGuildsReached = 30001
+ ErrCodeMaximumPinsReached = 30003
+ ErrCodeMaximumNumberOfRecipientsReached = 30004
+ ErrCodeMaximumGuildRolesReached = 30005
+ ErrCodeMaximumNumberOfWebhooksReached = 30007
+ ErrCodeMaximumNumberOfEmojisReached = 30008
+ ErrCodeTooManyReactions = 30010
+ ErrCodeMaximumNumberOfGuildChannelsReached = 30013
+ ErrCodeMaximumNumberOfAttachmentsInAMessageReached = 30015
+ ErrCodeMaximumNumberOfInvitesReached = 30016
+ ErrCodeMaximumNumberOfAnimatedEmojisReached = 30018
+ ErrCodeMaximumNumberOfServerMembersReached = 30019
+ ErrCodeMaximumNumberOfGuildDiscoverySubcategoriesReached = 30030
+ ErrCodeGuildAlreadyHasATemplate = 30031
+ ErrCodeMaximumNumberOfThreadParticipantsReached = 30033
+ ErrCodeMaximumNumberOfBansForNonGuildMembersHaveBeenExceeded = 30035
+ ErrCodeMaximumNumberOfBansFetchesHasBeenReached = 30037
+ ErrCodeMaximumNumberOfUncompletedGuildScheduledEventsReached = 30038
+ ErrCodeMaximumNumberOfStickersReached = 30039
+ ErrCodeMaximumNumberOfPruneRequestsHasBeenReached = 30040
+ ErrCodeMaximumNumberOfGuildWidgetSettingsUpdatesHasBeenReached = 30042
+ ErrCodeMaximumNumberOfEditsToMessagesOlderThanOneHourReached = 30046
+ ErrCodeMaximumNumberOfPinnedThreadsInForumChannelHasBeenReached = 30047
+ ErrCodeMaximumNumberOfTagsInForumChannelHasBeenReached = 30048
ErrCodeUnauthorized = 40001
ErrCodeActionRequiredVerifiedAccount = 40002
@@ -2121,6 +2271,7 @@ const (
ErrCodeMessageAlreadyCrossposted = 40033
ErrCodeAnApplicationWithThatNameAlreadyExists = 40041
ErrCodeInteractionHasAlreadyBeenAcknowledged = 40060
+ ErrCodeTagNamesMustBeUnique = 40061
ErrCodeMissingAccess = 50001
ErrCodeInvalidAccountType = 50002
diff --git a/vendor/github.com/bwmarrin/discordgo/util.go b/vendor/github.com/bwmarrin/discordgo/util.go
index 86f43b5f..957f3018 100644
--- a/vendor/github.com/bwmarrin/discordgo/util.go
+++ b/vendor/github.com/bwmarrin/discordgo/util.go
@@ -51,7 +51,7 @@ func MultipartBodyWithJSON(data interface{}, files []*File) (requestContentType
for i, file := range files {
h := make(textproto.MIMEHeader)
- h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="file%d"; filename="%s"`, i, quoteEscaper.Replace(file.Name)))
+ h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="files[%d]"; filename="%s"`, i, quoteEscaper.Replace(file.Name)))
contentType := file.ContentType
if contentType == "" {
contentType = "application/octet-stream"
@@ -107,3 +107,19 @@ func bannerURL(bannerHash, staticBannerURL, animatedBannerURL, size string) stri
}
return URL
}
+
+func iconURL(iconHash, staticIconURL, animatedIconURL, size string) string {
+ var URL string
+ if iconHash == "" {
+ return ""
+ } else if strings.HasPrefix(iconHash, "a_") {
+ URL = animatedIconURL
+ } else {
+ URL = staticIconURL
+ }
+
+ if size != "" {
+ return URL + "?size=" + size
+ }
+ return URL
+}
diff --git a/vendor/github.com/bwmarrin/discordgo/voice.go b/vendor/github.com/bwmarrin/discordgo/voice.go
index efd88090..87e84b12 100644
--- a/vendor/github.com/bwmarrin/discordgo/voice.go
+++ b/vendor/github.com/bwmarrin/discordgo/voice.go
@@ -360,6 +360,25 @@ func (v *VoiceConnection) wsListen(wsConn *websocket.Conn, close <-chan struct{}
v.wsConn = nil
v.Unlock()
+ // Wait for VOICE_SERVER_UPDATE.
+ // When the bot is moved by the user to another voice channel,
+ // VOICE_SERVER_UPDATE is received after the code 4014.
+ for i := 0; i < 5; i++ { // TODO: temp, wait for VoiceServerUpdate.
+ <-time.After(1 * time.Second)
+
+ v.RLock()
+ reconnected := v.wsConn != nil
+ v.RUnlock()
+ if !reconnected {
+ continue
+ }
+ v.log(LogInformational, "successfully reconnected after 4014 manual disconnection")
+ return
+ }
+
+ // When VOICE_SERVER_UPDATE is not received, disconnect as usual.
+ v.log(LogInformational, "disconnect due to 4014 manual disconnection")
+
v.session.Lock()
delete(v.session.VoiceConnections, v.GuildID)
v.session.Unlock()
@@ -835,7 +854,7 @@ func (v *VoiceConnection) opusReceiver(udpConn *net.UDPConn, close <-chan struct
if opus, ok := secretbox.Open(nil, recvbuf[12:rlen], &nonce, &v.op4.SecretKey); ok {
p.Opus = opus
} else {
- return
+ continue
}
// extension bit set, and not a RTCP packet
diff --git a/vendor/github.com/bwmarrin/discordgo/wsapi.go b/vendor/github.com/bwmarrin/discordgo/wsapi.go
index 2579ee42..6c823884 100644
--- a/vendor/github.com/bwmarrin/discordgo/wsapi.go
+++ b/vendor/github.com/bwmarrin/discordgo/wsapi.go
@@ -320,7 +320,7 @@ func (s *Session) heartbeat(wsConn *websocket.Conn, listening <-chan interface{}
}
}
-// UpdateStatusData ia provided to UpdateStatusComplex()
+// UpdateStatusData is provided to UpdateStatusComplex()
type UpdateStatusData struct {
IdleSince *int `json:"since"`
Activities []*Activity `json:"activities"`
@@ -361,6 +361,14 @@ func (s *Session) UpdateGameStatus(idle int, name string) (err error) {
return s.UpdateStatusComplex(*newUpdateStatusData(idle, ActivityTypeGame, name, ""))
}
+// UpdateWatchStatus is used to update the user's watch status.
+// If idle>0 then set status to idle.
+// If name!="" then set movie/stream.
+// if otherwise, set status to active, and no activity.
+func (s *Session) UpdateWatchStatus(idle int, name string) (err error) {
+ return s.UpdateStatusComplex(*newUpdateStatusData(idle, ActivityTypeWatching, name, ""))
+}
+
// UpdateStreamingStatus is used to update the user's streaming status.
// If idle>0 then set status to idle.
// If name!="" then set game.