aboutsummaryrefslogtreecommitdiff
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/.travis.yml2
-rw-r--r--vendor/github.com/bwmarrin/discordgo/CONTRIBUTING.md87
-rw-r--r--vendor/github.com/bwmarrin/discordgo/README.md8
-rw-r--r--vendor/github.com/bwmarrin/discordgo/components.go10
-rw-r--r--vendor/github.com/bwmarrin/discordgo/discord.go9
-rw-r--r--vendor/github.com/bwmarrin/discordgo/endpoints.go27
-rw-r--r--vendor/github.com/bwmarrin/discordgo/eventhandlers.go608
-rw-r--r--vendor/github.com/bwmarrin/discordgo/events.go110
-rw-r--r--vendor/github.com/bwmarrin/discordgo/interactions.go57
-rw-r--r--vendor/github.com/bwmarrin/discordgo/logging.go2
-rw-r--r--vendor/github.com/bwmarrin/discordgo/message.go20
-rw-r--r--vendor/github.com/bwmarrin/discordgo/restapi.go562
-rw-r--r--vendor/github.com/bwmarrin/discordgo/state.go20
-rw-r--r--vendor/github.com/bwmarrin/discordgo/structs.go514
-rw-r--r--vendor/github.com/bwmarrin/discordgo/types.go47
-rw-r--r--vendor/github.com/bwmarrin/discordgo/util.go3
-rw-r--r--vendor/github.com/bwmarrin/discordgo/voice.go21
-rw-r--r--vendor/github.com/bwmarrin/discordgo/webhook.go11
-rw-r--r--vendor/github.com/bwmarrin/discordgo/wsapi.go57
19 files changed, 1462 insertions, 713 deletions
diff --git a/vendor/github.com/bwmarrin/discordgo/.travis.yml b/vendor/github.com/bwmarrin/discordgo/.travis.yml
index 5d9cea3..e80d490 100644
--- a/vendor/github.com/bwmarrin/discordgo/.travis.yml
+++ b/vendor/github.com/bwmarrin/discordgo/.travis.yml
@@ -4,6 +4,8 @@ go:
- 1.14.x
- 1.15.x
- 1.16.x
+ - 1.17.x
+ - 1.18.x
env:
- GO111MODULE=on
install:
diff --git a/vendor/github.com/bwmarrin/discordgo/CONTRIBUTING.md b/vendor/github.com/bwmarrin/discordgo/CONTRIBUTING.md
new file mode 100644
index 0000000..85e9680
--- /dev/null
+++ b/vendor/github.com/bwmarrin/discordgo/CONTRIBUTING.md
@@ -0,0 +1,87 @@
+# Getting started
+
+To start off you can check out existing Pull Requests and Issues to get a gasp of what problems we’re currently solving and what features you can implement.
+
+## Issues
+
+Our issues are mostly used for bugs, however we welcome refactoring and conceptual issues.
+
+Any other conversation would belong and would be moved into “Discussions”.
+
+## Discussions
+
+We use discussions for ideas, polls, announcements and help questions.
+
+Don’t hesitate to ask, we always would try to help.
+
+## Pull Requests
+
+If you want to help us by improving existing or adding new features, you create what’s called a Pull Request (aka PR). It allows us to review your code, suggest changes and merge it.
+
+Here are some tips on how to make a good first PR:
+
+- When creating a PR, please consider a distinctive name and description for it, so the maintainers can understand what your PR changes / adds / removes.
+- It’s always a good idea to link documentation when implementing a new feature / endpoint
+- If you’re resolving an issue, don’t forget to [link it](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) in the description.
+- Enable the checkbox to allow maintainers to edit your PR and make commits in the PR branch when necessary.
+- We may ask for changes, usually through suggestions or pull request comments. You can apply suggestions right in the UI. Any other change needs to be done manually.
+- Don’t forget to mark PR comments resolved when you’re done applying the changes.
+- Be patient and don’t close and reopen your PR when no one responds, sometimes it might be held for a while. There might be a lot of reasons: release preparation, the feature is not significant, maintainers are busy, etc.
+
+
+When your changes are still incomplete (i.e. in Work In Progress state), you can still create a PR, but consider making it a draft.
+To make a draft PR, you can change the type of PR by clicking to a triangle next to the “Create Pull Request” button.
+
+Once you’re done, you can mark it as “Ready for review”, and we’ll get right on it.
+
+
+# Code style
+
+To standardize and make things less messy we have a certain code style, that is persistent throughout the codebase.
+
+## Naming
+
+### REST methods
+
+When naming a REST method, while it might seem counterintuitive, we specify the entity before the action verb (for GET endpoints we don’t specify one however). Here’s an example:
+
+> Endpoint name: Get Channel Message
+>
+> Method name: `ChannelMessage`
+
+> Endpoint name: Edit Channel Message
+>
+> Method name: `ChannelMessageEdit`
+
+### Parameter structures
+
+When making a complex REST endpoint, sometimes you might need to implement a `Param` structure. This structure contains parameters for certain endpoint/set of endpoints.
+
+- If an endpoint/set of endpoints have mostly same parameters, it’s a good idea to use a single `Param` structure for them. Here’s an example:
+
+ > Endpoint: `GuildMemberEdit`
+ >
+ > `Param` structure: `GuildMemberParams`
+- If an endpoint/set of endpoints have differentiating parameters, `Param` structure can be named after the endpoint’s verb. Here’s an example:
+
+ > Endpoint: `ChannelMessageSendComplex`
+ >
+ > `Param` structure: `MessageSend`
+
+ > Endpoint: `ChannelMessageEditComplex`
+ >
+ > `Param` structure: `MessageEdit`
+
+### Events
+
+When naming an event, we follow gateway’s internal naming (which often matches with the official event name in the docs). Here’s an example:
+
+> Event name: Interaction Create (`INTERACTION_CREATE`)
+>
+> Structure name: `InteractionCreate`
+
+## Returns
+
+In our REST functions we usually favor named returns instead of regular anonymous returns. This helps readability.
+
+Additionally we try to avoid naked return statements for functions with a long body. Since it’s easier to loose track of the return result.
diff --git a/vendor/github.com/bwmarrin/discordgo/README.md b/vendor/github.com/bwmarrin/discordgo/README.md
index 2bcd43b..d6ee0cc 100644
--- a/vendor/github.com/bwmarrin/discordgo/README.md
+++ b/vendor/github.com/bwmarrin/discordgo/README.md
@@ -1,6 +1,6 @@
# DiscordGo
-[![Go Reference](https://pkg.go.dev/badge/github.com/bwmarrin/discordgo.svg)](https://pkg.go.dev/github.com/bwmarrin/discordgo) [![Go Report Card](https://goreportcard.com/badge/github.com/bwmarrin/discordgo)](https://goreportcard.com/report/github.com/bwmarrin/discordgo) [![Build Status](https://travis-ci.com/bwmarrin/discordgo.svg?branch=master)](https://travis-ci.com/bwmarrin/discordgo) [![Discord Gophers](https://img.shields.io/badge/Discord%20Gophers-%23discordgo-blue.svg)](https://discord.gg/golang) [![Discord API](https://img.shields.io/badge/Discord%20API-%23go_discordgo-blue.svg)](https://discord.com/invite/discord-api)
+[![Go Reference](https://pkg.go.dev/badge/github.com/bwmarrin/discordgo.svg)](https://pkg.go.dev/github.com/bwmarrin/discordgo) [![Go Report Card](https://goreportcard.com/badge/github.com/bwmarrin/discordgo)](https://goreportcard.com/report/github.com/bwmarrin/discordgo) [![CI](https://github.com/bwmarrin/discordgo/actions/workflows/ci.yml/badge.svg)](https://github.com/bwmarrin/discordgo/actions/workflows/ci.yml) [![Discord Gophers](https://img.shields.io/badge/Discord%20Gophers-%23discordgo-blue.svg)](https://discord.gg/golang) [![Discord API](https://img.shields.io/badge/Discord%20API-%23go_discordgo-blue.svg)](https://discord.com/invite/discord-api)
<img align="right" alt="DiscordGo logo" src="docs/img/discordgo.svg" width="400">
@@ -61,11 +61,9 @@ See Documentation and Examples below for more detailed information.
Because of that there may be major changes to library in the future.
The DiscordGo code is fairly well documented at this point and is currently
-the only documentation available. Both GoDoc and GoWalker (below) present
-that information in a nice format.
+the only documentation available. Go reference (below) presents that information in a nice format.
-- [![Go Reference](https://pkg.go.dev/badge/github.com/bwmarrin/discordgo.svg)](https://pkg.go.dev/github.com/bwmarrin/discordgo)
-- [![Go Walker](https://gowalker.org/api/v1/badge)](https://gowalker.org/github.com/bwmarrin/discordgo)
+- [![Go Reference](https://pkg.go.dev/badge/github.com/bwmarrin/discordgo.svg)](https://pkg.go.dev/github.com/bwmarrin/discordgo)
- Hand crafted documentation coming eventually.
diff --git a/vendor/github.com/bwmarrin/discordgo/components.go b/vendor/github.com/bwmarrin/discordgo/components.go
index 00cbbf1..6ee4e28 100644
--- a/vendor/github.com/bwmarrin/discordgo/components.go
+++ b/vendor/github.com/bwmarrin/discordgo/components.go
@@ -70,7 +70,7 @@ type ActionsRow struct {
func (r ActionsRow) MarshalJSON() ([]byte, error) {
type actionsRow ActionsRow
- return json.Marshal(struct {
+ return Marshal(struct {
actionsRow
Type ComponentType `json:"type"`
}{
@@ -145,7 +145,7 @@ func (b Button) MarshalJSON() ([]byte, error) {
b.Style = PrimaryButton
}
- return json.Marshal(struct {
+ return Marshal(struct {
button
Type ComponentType `json:"type"`
}{
@@ -192,7 +192,7 @@ func (SelectMenu) Type() ComponentType {
func (m SelectMenu) MarshalJSON() ([]byte, error) {
type selectMenu SelectMenu
- return json.Marshal(struct {
+ return Marshal(struct {
selectMenu
Type ComponentType `json:"type"`
}{
@@ -208,7 +208,7 @@ type TextInput struct {
Style TextInputStyle `json:"style"`
Placeholder string `json:"placeholder,omitempty"`
Value string `json:"value,omitempty"`
- Required bool `json:"required,omitempty"`
+ Required bool `json:"required"`
MinLength int `json:"min_length,omitempty"`
MaxLength int `json:"max_length,omitempty"`
}
@@ -222,7 +222,7 @@ func (TextInput) Type() ComponentType {
func (m TextInput) MarshalJSON() ([]byte, error) {
type inputText TextInput
- return json.Marshal(struct {
+ return Marshal(struct {
inputText
Type ComponentType `json:"type"`
}{
diff --git a/vendor/github.com/bwmarrin/discordgo/discord.go b/vendor/github.com/bwmarrin/discordgo/discord.go
index 74f4190..fc7b6d7 100644
--- a/vendor/github.com/bwmarrin/discordgo/discord.go
+++ b/vendor/github.com/bwmarrin/discordgo/discord.go
@@ -17,10 +17,12 @@ import (
"net/http"
"runtime"
"time"
+
+ "github.com/gorilla/websocket"
)
// VERSION of DiscordGo, follows Semantic Versioning. (http://semver.org/)
-const VERSION = "0.24.0"
+const VERSION = "0.26.1"
// New creates a new Discord session with provided token.
// If the token is for a bot, it must be prefixed with "Bot "
@@ -36,20 +38,21 @@ func New(token string) (s *Session, err error) {
StateEnabled: true,
Compress: true,
ShouldReconnectOnError: true,
+ ShouldRetryOnRateLimit: true,
ShardID: 0,
ShardCount: 1,
MaxRestRetries: 3,
Client: &http.Client{Timeout: (20 * time.Second)},
+ Dialer: websocket.DefaultDialer,
UserAgent: "DiscordBot (https://github.com/bwmarrin/discordgo, v" + VERSION + ")",
sequence: new(int64),
LastHeartbeatAck: time.Now().UTC(),
}
- // Initilize the Identify Package with defaults
+ // Initialize the Identify Package with defaults
// These can be modified prior to calling Open()
s.Identify.Compress = true
s.Identify.LargeThreshold = 250
- s.Identify.GuildSubscriptions = true
s.Identify.Properties.OS = runtime.GOOS
s.Identify.Properties.Browser = "DiscordGo v" + VERSION
s.Identify.Intents = IntentsAllWithoutPrivileged
diff --git a/vendor/github.com/bwmarrin/discordgo/endpoints.go b/vendor/github.com/bwmarrin/discordgo/endpoints.go
index d39a175..375b75b 100644
--- a/vendor/github.com/bwmarrin/discordgo/endpoints.go
+++ b/vendor/github.com/bwmarrin/discordgo/endpoints.go
@@ -23,15 +23,16 @@ var (
EndpointSmActive = EndpointSm + "active.json"
EndpointSmUpcoming = EndpointSm + "upcoming.json"
- EndpointDiscord = "https://discord.com/"
- EndpointAPI = EndpointDiscord + "api/v" + APIVersion + "/"
- EndpointGuilds = EndpointAPI + "guilds/"
- EndpointChannels = EndpointAPI + "channels/"
- EndpointUsers = EndpointAPI + "users/"
- EndpointGateway = EndpointAPI + "gateway"
- EndpointGatewayBot = EndpointGateway + "/bot"
- EndpointWebhooks = EndpointAPI + "webhooks/"
- EndpointStickers = EndpointAPI + "stickers/"
+ EndpointDiscord = "https://discord.com/"
+ EndpointAPI = EndpointDiscord + "api/v" + APIVersion + "/"
+ EndpointGuilds = EndpointAPI + "guilds/"
+ EndpointChannels = EndpointAPI + "channels/"
+ EndpointUsers = EndpointAPI + "users/"
+ EndpointGateway = EndpointAPI + "gateway"
+ EndpointGatewayBot = EndpointGateway + "/bot"
+ EndpointWebhooks = EndpointAPI + "webhooks/"
+ EndpointStickers = EndpointAPI + "stickers/"
+ EndpointStageInstances = EndpointAPI + "stage-instances"
EndpointCDN = "https://cdn.discordapp.com/"
EndpointCDNAttachments = EndpointCDN + "attachments/"
@@ -45,8 +46,6 @@ var (
EndpointVoice = EndpointAPI + "/voice/"
EndpointVoiceRegions = EndpointVoice + "regions"
- // TODO: EndpointUserGuildMember
-
EndpointUser = func(uID string) string { return EndpointUsers + uID }
EndpointUserAvatar = func(uID, aID string) string { return EndpointCDNAvatars + uID + "/" + aID + ".png" }
EndpointUserAvatarAnimated = func(uID, aID string) string { return EndpointCDNAvatars + uID + "/" + aID + ".gif" }
@@ -63,15 +62,20 @@ var (
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" }
EndpointGuild = func(gID string) string { return EndpointGuilds + gID }
+ EndpointGuildAutoModeration = func(gID string) string { return EndpointGuild(gID) + "/auto-moderation" }
+ EndpointGuildAutoModerationRules = func(gID string) string { return EndpointGuildAutoModeration(gID) + "/rules" }
+ EndpointGuildAutoModerationRule = func(gID, rID string) string { return EndpointGuildAutoModerationRules(gID) + "/" + rID }
EndpointGuildThreads = func(gID string) string { return EndpointGuild(gID) + "/threads" }
EndpointGuildActiveThreads = func(gID string) string { return EndpointGuildThreads(gID) + "/active" }
EndpointGuildPreview = func(gID string) string { return EndpointGuilds + gID + "/preview" }
EndpointGuildChannels = func(gID string) string { return EndpointGuilds + gID + "/channels" }
EndpointGuildMembers = func(gID string) string { return EndpointGuilds + gID + "/members" }
+ EndpointGuildMembersSearch = func(gID string) string { return EndpointGuildMembers(gID) + "/search" }
EndpointGuildMember = func(gID, uID string) string { return EndpointGuilds + gID + "/members/" + uID }
EndpointGuildMemberRole = func(gID, uID, rID string) string { return EndpointGuilds + gID + "/members/" + uID + "/roles/" + rID }
EndpointGuildBans = func(gID string) string { return EndpointGuilds + gID + "/bans" }
@@ -94,6 +98,7 @@ var (
EndpointGuildBanner = func(gID, hash string) string { return EndpointCDNBanners + gID + "/" + hash + ".png" }
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 }
EndpointGuildScheduledEvents = func(gID string) string { return EndpointGuilds + gID + "/scheduled-events" }
EndpointGuildScheduledEvent = func(gID, eID string) string { return EndpointGuilds + gID + "/scheduled-events/" + eID }
EndpointGuildScheduledEventUsers = func(gID, eID string) string { return EndpointGuildScheduledEvent(gID, eID) + "/users" }
diff --git a/vendor/github.com/bwmarrin/discordgo/eventhandlers.go b/vendor/github.com/bwmarrin/discordgo/eventhandlers.go
index 18d6248..9f69a60 100644
--- a/vendor/github.com/bwmarrin/discordgo/eventhandlers.go
+++ b/vendor/github.com/bwmarrin/discordgo/eventhandlers.go
@@ -7,64 +7,168 @@ package discordgo
// Event type values are used to match the events returned by Discord.
// EventTypes surrounded by __ are synthetic and are internal to DiscordGo.
const (
- channelCreateEventType = "CHANNEL_CREATE"
- channelDeleteEventType = "CHANNEL_DELETE"
- channelPinsUpdateEventType = "CHANNEL_PINS_UPDATE"
- channelUpdateEventType = "CHANNEL_UPDATE"
- connectEventType = "__CONNECT__"
- disconnectEventType = "__DISCONNECT__"
- eventEventType = "__EVENT__"
- guildBanAddEventType = "GUILD_BAN_ADD"
- guildBanRemoveEventType = "GUILD_BAN_REMOVE"
- guildCreateEventType = "GUILD_CREATE"
- guildDeleteEventType = "GUILD_DELETE"
- guildEmojisUpdateEventType = "GUILD_EMOJIS_UPDATE"
- guildIntegrationsUpdateEventType = "GUILD_INTEGRATIONS_UPDATE"
- guildMemberAddEventType = "GUILD_MEMBER_ADD"
- guildMemberRemoveEventType = "GUILD_MEMBER_REMOVE"
- guildMemberUpdateEventType = "GUILD_MEMBER_UPDATE"
- guildMembersChunkEventType = "GUILD_MEMBERS_CHUNK"
- guildRoleCreateEventType = "GUILD_ROLE_CREATE"
- guildRoleDeleteEventType = "GUILD_ROLE_DELETE"
- guildRoleUpdateEventType = "GUILD_ROLE_UPDATE"
- guildUpdateEventType = "GUILD_UPDATE"
- guildScheduledEventCreateEventType = "GUILD_SCHEDULED_EVENT_CREATE"
- guildScheduledEventUpdateEventType = "GUILD_SCHEDULED_EVENT_UPDATE"
- guildScheduledEventDeleteEventType = "GUILD_SCHEDULED_EVENT_DELETE"
- interactionCreateEventType = "INTERACTION_CREATE"
- inviteCreateEventType = "INVITE_CREATE"
- inviteDeleteEventType = "INVITE_DELETE"
- messageAckEventType = "MESSAGE_ACK"
- messageCreateEventType = "MESSAGE_CREATE"
- messageDeleteEventType = "MESSAGE_DELETE"
- messageDeleteBulkEventType = "MESSAGE_DELETE_BULK"
- messageReactionAddEventType = "MESSAGE_REACTION_ADD"
- messageReactionRemoveEventType = "MESSAGE_REACTION_REMOVE"
- messageReactionRemoveAllEventType = "MESSAGE_REACTION_REMOVE_ALL"
- messageUpdateEventType = "MESSAGE_UPDATE"
- presenceUpdateEventType = "PRESENCE_UPDATE"
- presencesReplaceEventType = "PRESENCES_REPLACE"
- rateLimitEventType = "__RATE_LIMIT__"
- readyEventType = "READY"
- relationshipAddEventType = "RELATIONSHIP_ADD"
- relationshipRemoveEventType = "RELATIONSHIP_REMOVE"
- resumedEventType = "RESUMED"
- threadCreateEventType = "THREAD_CREATE"
- threadDeleteEventType = "THREAD_DELETE"
- threadListSyncEventType = "THREAD_LIST_SYNC"
- threadMemberUpdateEventType = "THREAD_MEMBER_UPDATE"
- threadMembersUpdateEventType = "THREAD_MEMBERS_UPDATE"
- threadUpdateEventType = "THREAD_UPDATE"
- typingStartEventType = "TYPING_START"
- userGuildSettingsUpdateEventType = "USER_GUILD_SETTINGS_UPDATE"
- userNoteUpdateEventType = "USER_NOTE_UPDATE"
- userSettingsUpdateEventType = "USER_SETTINGS_UPDATE"
- userUpdateEventType = "USER_UPDATE"
- voiceServerUpdateEventType = "VOICE_SERVER_UPDATE"
- voiceStateUpdateEventType = "VOICE_STATE_UPDATE"
- webhooksUpdateEventType = "WEBHOOKS_UPDATE"
+ applicationCommandPermissionsUpdateEventType = "APPLICATION_COMMAND_PERMISSIONS_UPDATE"
+ autoModerationActionExecutionEventType = "AUTO_MODERATION_ACTION_EXECUTION"
+ autoModerationRuleCreateEventType = "AUTO_MODERATION_RULE_CREATE"
+ autoModerationRuleDeleteEventType = "AUTO_MODERATION_RULE_DELETE"
+ autoModerationRuleUpdateEventType = "AUTO_MODERATION_RULE_UPDATE"
+ channelCreateEventType = "CHANNEL_CREATE"
+ channelDeleteEventType = "CHANNEL_DELETE"
+ channelPinsUpdateEventType = "CHANNEL_PINS_UPDATE"
+ channelUpdateEventType = "CHANNEL_UPDATE"
+ connectEventType = "__CONNECT__"
+ disconnectEventType = "__DISCONNECT__"
+ eventEventType = "__EVENT__"
+ guildBanAddEventType = "GUILD_BAN_ADD"
+ guildBanRemoveEventType = "GUILD_BAN_REMOVE"
+ guildCreateEventType = "GUILD_CREATE"
+ guildDeleteEventType = "GUILD_DELETE"
+ guildEmojisUpdateEventType = "GUILD_EMOJIS_UPDATE"
+ guildIntegrationsUpdateEventType = "GUILD_INTEGRATIONS_UPDATE"
+ guildMemberAddEventType = "GUILD_MEMBER_ADD"
+ guildMemberRemoveEventType = "GUILD_MEMBER_REMOVE"
+ guildMemberUpdateEventType = "GUILD_MEMBER_UPDATE"
+ guildMembersChunkEventType = "GUILD_MEMBERS_CHUNK"
+ guildRoleCreateEventType = "GUILD_ROLE_CREATE"
+ guildRoleDeleteEventType = "GUILD_ROLE_DELETE"
+ guildRoleUpdateEventType = "GUILD_ROLE_UPDATE"
+ guildScheduledEventCreateEventType = "GUILD_SCHEDULED_EVENT_CREATE"
+ guildScheduledEventDeleteEventType = "GUILD_SCHEDULED_EVENT_DELETE"
+ guildScheduledEventUpdateEventType = "GUILD_SCHEDULED_EVENT_UPDATE"
+ guildScheduledEventUserAddEventType = "GUILD_SCHEDULED_EVENT_USER_ADD"
+ guildScheduledEventUserRemoveEventType = "GUILD_SCHEDULED_EVENT_USER_REMOVE"
+ guildUpdateEventType = "GUILD_UPDATE"
+ interactionCreateEventType = "INTERACTION_CREATE"
+ inviteCreateEventType = "INVITE_CREATE"
+ inviteDeleteEventType = "INVITE_DELETE"
+ messageCreateEventType = "MESSAGE_CREATE"
+ messageDeleteEventType = "MESSAGE_DELETE"
+ messageDeleteBulkEventType = "MESSAGE_DELETE_BULK"
+ messageReactionAddEventType = "MESSAGE_REACTION_ADD"
+ messageReactionRemoveEventType = "MESSAGE_REACTION_REMOVE"
+ messageReactionRemoveAllEventType = "MESSAGE_REACTION_REMOVE_ALL"
+ messageUpdateEventType = "MESSAGE_UPDATE"
+ presenceUpdateEventType = "PRESENCE_UPDATE"
+ presencesReplaceEventType = "PRESENCES_REPLACE"
+ rateLimitEventType = "__RATE_LIMIT__"
+ readyEventType = "READY"
+ resumedEventType = "RESUMED"
+ stageInstanceEventCreateEventType = "STAGE_INSTANCE_EVENT_CREATE"
+ stageInstanceEventDeleteEventType = "STAGE_INSTANCE_EVENT_DELETE"
+ stageInstanceEventUpdateEventType = "STAGE_INSTANCE_EVENT_UPDATE"
+ threadCreateEventType = "THREAD_CREATE"
+ threadDeleteEventType = "THREAD_DELETE"
+ threadListSyncEventType = "THREAD_LIST_SYNC"
+ threadMemberUpdateEventType = "THREAD_MEMBER_UPDATE"
+ threadMembersUpdateEventType = "THREAD_MEMBERS_UPDATE"
+ threadUpdateEventType = "THREAD_UPDATE"
+ typingStartEventType = "TYPING_START"
+ userUpdateEventType = "USER_UPDATE"
+ voiceServerUpdateEventType = "VOICE_SERVER_UPDATE"
+ voiceStateUpdateEventType = "VOICE_STATE_UPDATE"
+ webhooksUpdateEventType = "WEBHOOKS_UPDATE"
)
+// applicationCommandPermissionsUpdateEventHandler is an event handler for ApplicationCommandPermissionsUpdate events.
+type applicationCommandPermissionsUpdateEventHandler func(*Session, *ApplicationCommandPermissionsUpdate)
+
+// Type returns the event type for ApplicationCommandPermissionsUpdate events.
+func (eh applicationCommandPermissionsUpdateEventHandler) Type() string {
+ return applicationCommandPermissionsUpdateEventType
+}
+
+// New returns a new instance of ApplicationCommandPermissionsUpdate.
+func (eh applicationCommandPermissionsUpdateEventHandler) New() interface{} {
+ return &ApplicationCommandPermissionsUpdate{}
+}
+
+// Handle is the handler for ApplicationCommandPermissionsUpdate events.
+func (eh applicationCommandPermissionsUpdateEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*ApplicationCommandPermissionsUpdate); ok {
+ eh(s, t)
+ }
+}
+
+// autoModerationActionExecutionEventHandler is an event handler for AutoModerationActionExecution events.
+type autoModerationActionExecutionEventHandler func(*Session, *AutoModerationActionExecution)
+
+// Type returns the event type for AutoModerationActionExecution events.
+func (eh autoModerationActionExecutionEventHandler) Type() string {
+ return autoModerationActionExecutionEventType
+}
+
+// New returns a new instance of AutoModerationActionExecution.
+func (eh autoModerationActionExecutionEventHandler) New() interface{} {
+ return &AutoModerationActionExecution{}
+}
+
+// Handle is the handler for AutoModerationActionExecution events.
+func (eh autoModerationActionExecutionEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*AutoModerationActionExecution); ok {
+ eh(s, t)
+ }
+}
+
+// autoModerationRuleCreateEventHandler is an event handler for AutoModerationRuleCreate events.
+type autoModerationRuleCreateEventHandler func(*Session, *AutoModerationRuleCreate)
+
+// Type returns the event type for AutoModerationRuleCreate events.
+func (eh autoModerationRuleCreateEventHandler) Type() string {
+ return autoModerationRuleCreateEventType
+}
+
+// New returns a new instance of AutoModerationRuleCreate.
+func (eh autoModerationRuleCreateEventHandler) New() interface{} {
+ return &AutoModerationRuleCreate{}
+}
+
+// Handle is the handler for AutoModerationRuleCreate events.
+func (eh autoModerationRuleCreateEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*AutoModerationRuleCreate); ok {
+ eh(s, t)
+ }
+}
+
+// autoModerationRuleDeleteEventHandler is an event handler for AutoModerationRuleDelete events.
+type autoModerationRuleDeleteEventHandler func(*Session, *AutoModerationRuleDelete)
+
+// Type returns the event type for AutoModerationRuleDelete events.
+func (eh autoModerationRuleDeleteEventHandler) Type() string {
+ return autoModerationRuleDeleteEventType
+}
+
+// New returns a new instance of AutoModerationRuleDelete.
+func (eh autoModerationRuleDeleteEventHandler) New() interface{} {
+ return &AutoModerationRuleDelete{}
+}
+
+// Handle is the handler for AutoModerationRuleDelete events.
+func (eh autoModerationRuleDeleteEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*AutoModerationRuleDelete); ok {
+ eh(s, t)
+ }
+}
+
+// autoModerationRuleUpdateEventHandler is an event handler for AutoModerationRuleUpdate events.
+type autoModerationRuleUpdateEventHandler func(*Session, *AutoModerationRuleUpdate)
+
+// Type returns the event type for AutoModerationRuleUpdate events.
+func (eh autoModerationRuleUpdateEventHandler) Type() string {
+ return autoModerationRuleUpdateEventType
+}
+
+// New returns a new instance of AutoModerationRuleUpdate.
+func (eh autoModerationRuleUpdateEventHandler) New() interface{} {
+ return &AutoModerationRuleUpdate{}
+}
+
+// Handle is the handler for AutoModerationRuleUpdate events.
+func (eh autoModerationRuleUpdateEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*AutoModerationRuleUpdate); ok {
+ eh(s, t)
+ }
+}
+
// channelCreateEventHandler is an event handler for ChannelCreate events.
type channelCreateEventHandler func(*Session, *ChannelCreate)
@@ -310,66 +414,6 @@ func (eh guildIntegrationsUpdateEventHandler) Handle(s *Session, i interface{})
}
}
-// guildScheduledEventCreateEventHandler is an event handler for GuildScheduledEventCreate events.
-type guildScheduledEventCreateEventHandler func(*Session, *GuildScheduledEventCreate)
-
-// Type returns the event type for GuildScheduledEventCreate events.
-func (eh guildScheduledEventCreateEventHandler) Type() string {
- return guildScheduledEventCreateEventType
-}
-
-// New returns a new instance of GuildScheduledEventCreate.
-func (eh guildScheduledEventCreateEventHandler) New() interface{} {
- return &GuildScheduledEventCreate{}
-}
-
-// Handle is the handler for GuildScheduledEventCreate events.
-func (eh guildScheduledEventCreateEventHandler) Handle(s *Session, i interface{}) {
- if t, ok := i.(*GuildScheduledEventCreate); ok {
- eh(s, t)
- }
-}
-
-// guildScheduledEventUpdateEventHandler is an event handler for GuildScheduledEventUpdate events.
-type guildScheduledEventUpdateEventHandler func(*Session, *GuildScheduledEventUpdate)
-
-// Type returns the event type for GuildScheduledEventUpdate events.
-func (eh guildScheduledEventUpdateEventHandler) Type() string {
- return guildScheduledEventUpdateEventType
-}
-
-// New returns a new instance of GuildScheduledEventUpdate.
-func (eh guildScheduledEventUpdateEventHandler) New() interface{} {
- return &GuildScheduledEventUpdate{}
-}
-
-// Handle is the handler for GuildScheduledEventUpdate events.
-func (eh guildScheduledEventUpdateEventHandler) Handle(s *Session, i interface{}) {
- if t, ok := i.(*GuildScheduledEventUpdate); ok {
- eh(s, t)
- }
-}
-
-// guildScheduledEventDeleteEventHandler is an event handler for GuildScheduledEventDelete events.
-type guildScheduledEventDeleteEventHandler func(*Session, *GuildScheduledEventDelete)
-
-// Type returns the event type for GuildScheduledEventDelete events.
-func (eh guildScheduledEventDeleteEventHandler) Type() string {
- return guildScheduledEventDeleteEventType
-}
-
-// New returns a new instance of GuildScheduledEventDelete.
-func (eh guildScheduledEventDeleteEventHandler) New() interface{} {
- return &GuildScheduledEventDelete{}
-}
-
-// Handle is the handler for GuildScheduledEventDelete events.
-func (eh guildScheduledEventDeleteEventHandler) Handle(s *Session, i interface{}) {
- if t, ok := i.(*GuildScheduledEventDelete); ok {
- eh(s, t)
- }
-}
-
// guildMemberAddEventHandler is an event handler for GuildMemberAdd events.
type guildMemberAddEventHandler func(*Session, *GuildMemberAdd)
@@ -510,6 +554,106 @@ func (eh guildRoleUpdateEventHandler) Handle(s *Session, i interface{}) {
}
}
+// guildScheduledEventCreateEventHandler is an event handler for GuildScheduledEventCreate events.
+type guildScheduledEventCreateEventHandler func(*Session, *GuildScheduledEventCreate)
+
+// Type returns the event type for GuildScheduledEventCreate events.
+func (eh guildScheduledEventCreateEventHandler) Type() string {
+ return guildScheduledEventCreateEventType
+}
+
+// New returns a new instance of GuildScheduledEventCreate.
+func (eh guildScheduledEventCreateEventHandler) New() interface{} {
+ return &GuildScheduledEventCreate{}
+}
+
+// Handle is the handler for GuildScheduledEventCreate events.
+func (eh guildScheduledEventCreateEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*GuildScheduledEventCreate); ok {
+ eh(s, t)
+ }
+}
+
+// guildScheduledEventDeleteEventHandler is an event handler for GuildScheduledEventDelete events.
+type guildScheduledEventDeleteEventHandler func(*Session, *GuildScheduledEventDelete)
+
+// Type returns the event type for GuildScheduledEventDelete events.
+func (eh guildScheduledEventDeleteEventHandler) Type() string {
+ return guildScheduledEventDeleteEventType
+}
+
+// New returns a new instance of GuildScheduledEventDelete.
+func (eh guildScheduledEventDeleteEventHandler) New() interface{} {
+ return &GuildScheduledEventDelete{}
+}
+
+// Handle is the handler for GuildScheduledEventDelete events.
+func (eh guildScheduledEventDeleteEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*GuildScheduledEventDelete); ok {
+ eh(s, t)
+ }
+}
+
+// guildScheduledEventUpdateEventHandler is an event handler for GuildScheduledEventUpdate events.
+type guildScheduledEventUpdateEventHandler func(*Session, *GuildScheduledEventUpdate)
+
+// Type returns the event type for GuildScheduledEventUpdate events.
+func (eh guildScheduledEventUpdateEventHandler) Type() string {
+ return guildScheduledEventUpdateEventType
+}
+
+// New returns a new instance of GuildScheduledEventUpdate.
+func (eh guildScheduledEventUpdateEventHandler) New() interface{} {
+ return &GuildScheduledEventUpdate{}
+}
+
+// Handle is the handler for GuildScheduledEventUpdate events.
+func (eh guildScheduledEventUpdateEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*GuildScheduledEventUpdate); ok {
+ eh(s, t)
+ }
+}
+
+// guildScheduledEventUserAddEventHandler is an event handler for GuildScheduledEventUserAdd events.
+type guildScheduledEventUserAddEventHandler func(*Session, *GuildScheduledEventUserAdd)
+
+// Type returns the event type for GuildScheduledEventUserAdd events.
+func (eh guildScheduledEventUserAddEventHandler) Type() string {
+ return guildScheduledEventUserAddEventType
+}
+
+// New returns a new instance of GuildScheduledEventUserAdd.
+func (eh guildScheduledEventUserAddEventHandler) New() interface{} {
+ return &GuildScheduledEventUserAdd{}
+}
+
+// Handle is the handler for GuildScheduledEventUserAdd events.
+func (eh guildScheduledEventUserAddEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*GuildScheduledEventUserAdd); ok {
+ eh(s, t)
+ }
+}
+
+// guildScheduledEventUserRemoveEventHandler is an event handler for GuildScheduledEventUserRemove events.
+type guildScheduledEventUserRemoveEventHandler func(*Session, *GuildScheduledEventUserRemove)
+
+// Type returns the event type for GuildScheduledEventUserRemove events.
+func (eh guildScheduledEventUserRemoveEventHandler) Type() string {
+ return guildScheduledEventUserRemoveEventType
+}
+
+// New returns a new instance of GuildScheduledEventUserRemove.
+func (eh guildScheduledEventUserRemoveEventHandler) New() interface{} {
+ return &GuildScheduledEventUserRemove{}
+}
+
+// Handle is the handler for GuildScheduledEventUserRemove events.
+func (eh guildScheduledEventUserRemoveEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*GuildScheduledEventUserRemove); ok {
+ eh(s, t)
+ }
+}
+
// guildUpdateEventHandler is an event handler for GuildUpdate events.
type guildUpdateEventHandler func(*Session, *GuildUpdate)
@@ -590,26 +734,6 @@ func (eh inviteDeleteEventHandler) Handle(s *Session, i interface{}) {
}
}
-// messageAckEventHandler is an event handler for MessageAck events.
-type messageAckEventHandler func(*Session, *MessageAck)
-
-// Type returns the event type for MessageAck events.
-func (eh messageAckEventHandler) Type() string {
- return messageAckEventType
-}
-
-// New returns a new instance of MessageAck.
-func (eh messageAckEventHandler) New() interface{} {
- return &MessageAck{}
-}
-
-// Handle is the handler for MessageAck events.
-func (eh messageAckEventHandler) Handle(s *Session, i interface{}) {
- if t, ok := i.(*MessageAck); ok {
- eh(s, t)
- }
-}
-
// messageCreateEventHandler is an event handler for MessageCreate events.
type messageCreateEventHandler func(*Session, *MessageCreate)
@@ -825,62 +949,82 @@ func (eh readyEventHandler) Handle(s *Session, i interface{}) {
}
}
-// relationshipAddEventHandler is an event handler for RelationshipAdd events.
-type relationshipAddEventHandler func(*Session, *RelationshipAdd)
+// resumedEventHandler is an event handler for Resumed events.
+type resumedEventHandler func(*Session, *Resumed)
+
+// Type returns the event type for Resumed events.
+func (eh resumedEventHandler) Type() string {
+ return resumedEventType
+}
+
+// New returns a new instance of Resumed.
+func (eh resumedEventHandler) New() interface{} {
+ return &Resumed{}
+}
+
+// Handle is the handler for Resumed events.
+func (eh resumedEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*Resumed); ok {
+ eh(s, t)
+ }
+}
+
+// stageInstanceEventCreateEventHandler is an event handler for StageInstanceEventCreate events.
+type stageInstanceEventCreateEventHandler func(*Session, *StageInstanceEventCreate)
-// Type returns the event type for RelationshipAdd events.
-func (eh relationshipAddEventHandler) Type() string {
- return relationshipAddEventType
+// Type returns the event type for StageInstanceEventCreate events.
+func (eh stageInstanceEventCreateEventHandler) Type() string {
+ return stageInstanceEventCreateEventType
}
-// New returns a new instance of RelationshipAdd.
-func (eh relationshipAddEventHandler) New() interface{} {
- return &RelationshipAdd{}
+// New returns a new instance of StageInstanceEventCreate.
+func (eh stageInstanceEventCreateEventHandler) New() interface{} {
+ return &StageInstanceEventCreate{}
}
-// Handle is the handler for RelationshipAdd events.
-func (eh relationshipAddEventHandler) Handle(s *Session, i interface{}) {
- if t, ok := i.(*RelationshipAdd); ok {
+// Handle is the handler for StageInstanceEventCreate events.
+func (eh stageInstanceEventCreateEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*StageInstanceEventCreate); ok {
eh(s, t)
}
}
-// relationshipRemoveEventHandler is an event handler for RelationshipRemove events.
-type relationshipRemoveEventHandler func(*Session, *RelationshipRemove)
+// stageInstanceEventDeleteEventHandler is an event handler for StageInstanceEventDelete events.
+type stageInstanceEventDeleteEventHandler func(*Session, *StageInstanceEventDelete)
-// Type returns the event type for RelationshipRemove events.
-func (eh relationshipRemoveEventHandler) Type() string {
- return relationshipRemoveEventType
+// Type returns the event type for StageInstanceEventDelete events.
+func (eh stageInstanceEventDeleteEventHandler) Type() string {
+ return stageInstanceEventDeleteEventType
}
-// New returns a new instance of RelationshipRemove.
-func (eh relationshipRemoveEventHandler) New() interface{} {
- return &RelationshipRemove{}
+// New returns a new instance of StageInstanceEventDelete.
+func (eh stageInstanceEventDeleteEventHandler) New() interface{} {
+ return &StageInstanceEventDelete{}
}
-// Handle is the handler for RelationshipRemove events.
-func (eh relationshipRemoveEventHandler) Handle(s *Session, i interface{}) {
- if t, ok := i.(*RelationshipRemove); ok {
+// Handle is the handler for StageInstanceEventDelete events.
+func (eh stageInstanceEventDeleteEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*StageInstanceEventDelete); ok {
eh(s, t)
}
}
-// resumedEventHandler is an event handler for Resumed events.
-type resumedEventHandler func(*Session, *Resumed)
+// stageInstanceEventUpdateEventHandler is an event handler for StageInstanceEventUpdate events.
+type stageInstanceEventUpdateEventHandler func(*Session, *StageInstanceEventUpdate)
-// Type returns the event type for Resumed events.
-func (eh resumedEventHandler) Type() string {
- return resumedEventType
+// Type returns the event type for StageInstanceEventUpdate events.
+func (eh stageInstanceEventUpdateEventHandler) Type() string {
+ return stageInstanceEventUpdateEventType
}
-// New returns a new instance of Resumed.
-func (eh resumedEventHandler) New() interface{} {
- return &Resumed{}
+// New returns a new instance of StageInstanceEventUpdate.
+func (eh stageInstanceEventUpdateEventHandler) New() interface{} {
+ return &StageInstanceEventUpdate{}
}
-// Handle is the handler for Resumed events.
-func (eh resumedEventHandler) Handle(s *Session, i interface{}) {
- if t, ok := i.(*Resumed); ok {
+// Handle is the handler for StageInstanceEventUpdate events.
+func (eh stageInstanceEventUpdateEventHandler) Handle(s *Session, i interface{}) {
+ if t, ok := i.(*StageInstanceEventUpdate); ok {
eh(s, t)
}
}
@@ -1025,66 +1169,6 @@ func (eh typingStartEventHandler) Handle(s *Session, i interface{}) {
}
}
-// userGuildSettingsUpdateEventHandler is an event handler for UserGuildSettingsUpdate events.
-type userGuildSettingsUpdateEventHandler func(*Session, *UserGuildSettingsUpdate)
-
-// Type returns the event type for UserGuildSettingsUpdate events.
-func (eh userGuildSettingsUpdateEventHandler) Type() string {
- return userGuildSettingsUpdateEventType
-}
-
-// New returns a new instance of UserGuildSettingsUpdate.
-func (eh userGuildSettingsUpdateEventHandler) New() interface{} {
- return &UserGuildSettingsUpdate{}
-}
-
-// Handle is the handler for UserGuildSettingsUpdate events.
-func (eh userGuildSettingsUpdateEventHandler) Handle(s *Session, i interface{}) {
- if t, ok := i.(*UserGuildSettingsUpdate); ok {
- eh(s, t)
- }
-}
-
-// userNoteUpdateEventHandler is an event handler for UserNoteUpdate events.
-type userNoteUpdateEventHandler func(*Session, *UserNoteUpdate)
-
-// Type returns the event type for UserNoteUpdate events.
-func (eh userNoteUpdateEventHandler) Type() string {
- return userNoteUpdateEventType
-}
-
-// New returns a new instance of UserNoteUpdate.
-func (eh userNoteUpdateEventHandler) New() interface{} {
- return &UserNoteUpdate{}
-}
-
-// Handle is the handler for UserNoteUpdate events.
-func (eh userNoteUpdateEventHandler) Handle(s *Session, i interface{}) {
- if t, ok := i.(*UserNoteUpdate); ok {
- eh(s, t)
- }
-}
-
-// userSettingsUpdateEventHandler is an event handler for UserSettingsUpdate events.
-type userSettingsUpdateEventHandler func(*Session, *UserSettingsUpdate)
-
-// Type returns the event type for UserSettingsUpdate events.
-func (eh userSettingsUpdateEventHandler) Type() string {
- return userSettingsUpdateEventType
-}
-
-// New returns a new instance of UserSettingsUpdate.
-func (eh userSettingsUpdateEventHandler) New() interface{} {
- return &UserSettingsUpdate{}
-}
-
-// Handle is the handler for UserSettingsUpdate events.
-func (eh userSettingsUpdateEventHandler) Handle(s *Session, i interface{}) {
- if t, ok := i.(*UserSettingsUpdate); ok {
- eh(s, t)
- }
-}
-
// userUpdateEventHandler is an event handler for UserUpdate events.
type userUpdateEventHandler func(*Session, *UserUpdate)
@@ -1169,6 +1253,16 @@ func handlerForInterface(handler interface{}) EventHandler {
switch v := handler.(type) {
case func(*Session, interface{}):
return interfaceEventHandler(v)
+ case func(*Session, *ApplicationCommandPermissionsUpdate):
+ return applicationCommandPermissionsUpdateEventHandler(v)
+ case func(*Session, *AutoModerationActionExecution):
+ return autoModerationActionExecutionEventHandler(v)
+ case func(*Session, *AutoModerationRuleCreate):
+ return autoModerationRuleCreateEventHandler(v)
+ case func(*Session, *AutoModerationRuleDelete):
+ return autoModerationRuleDeleteEventHandler(v)
+ case func(*Session, *AutoModerationRuleUpdate):
+ return autoModerationRuleUpdateEventHandler(v)
case func(*Session, *ChannelCreate):
return channelCreateEventHandler(v)
case func(*Session, *ChannelDelete):
@@ -1195,12 +1289,6 @@ func handlerForInterface(handler interface{}) EventHandler {
return guildEmojisUpdateEventHandler(v)
case func(*Session, *GuildIntegrationsUpdate):
return guildIntegrationsUpdateEventHandler(v)
- case func(*Session, *GuildScheduledEventCreate):
- return guildScheduledEventCreateEventHandler(v)
- case func(*Session, *GuildScheduledEventUpdate):
- return guildScheduledEventUpdateEventHandler(v)
- case func(*Session, *GuildScheduledEventDelete):
- return guildScheduledEventDeleteEventHandler(v)
case func(*Session, *GuildMemberAdd):
return guildMemberAddEventHandler(v)
case func(*Session, *GuildMemberRemove):
@@ -1215,6 +1303,16 @@ func handlerForInterface(handler interface{}) EventHandler {
return guildRoleDeleteEventHandler(v)
case func(*Session, *GuildRoleUpdate):
return guildRoleUpdateEventHandler(v)
+ case func(*Session, *GuildScheduledEventCreate):
+ return guildScheduledEventCreateEventHandler(v)
+ case func(*Session, *GuildScheduledEventDelete):
+ return guildScheduledEventDeleteEventHandler(v)
+ case func(*Session, *GuildScheduledEventUpdate):
+ return guildScheduledEventUpdateEventHandler(v)
+ case func(*Session, *GuildScheduledEventUserAdd):
+ return guildScheduledEventUserAddEventHandler(v)
+ case func(*Session, *GuildScheduledEventUserRemove):
+ return guildScheduledEventUserRemoveEventHandler(v)
case func(*Session, *GuildUpdate):
return guildUpdateEventHandler(v)
case func(*Session, *InteractionCreate):
@@ -1223,8 +1321,6 @@ func handlerForInterface(handler interface{}) EventHandler {
return inviteCreateEventHandler(v)
case func(*Session, *InviteDelete):
return inviteDeleteEventHandler(v)
- case func(*Session, *MessageAck):
- return messageAckEventHandler(v)
case func(*Session, *MessageCreate):
return messageCreateEventHandler(v)
case func(*Session, *MessageDelete):
@@ -1247,12 +1343,14 @@ func handlerForInterface(handler interface{}) EventHandler {
return rateLimitEventHandler(v)
case func(*Session, *Ready):
return readyEventHandler(v)
- case func(*Session, *RelationshipAdd):
- return relationshipAddEventHandler(v)
- case func(*Session, *RelationshipRemove):
- return relationshipRemoveEventHandler(v)
case func(*Session, *Resumed):
return resumedEventHandler(v)
+ case func(*Session, *StageInstanceEventCreate):
+ return stageInstanceEventCreateEventHandler(v)
+ case func(*Session, *StageInstanceEventDelete):
+ return stageInstanceEventDeleteEventHandler(v)
+ case func(*Session, *StageInstanceEventUpdate):
+ return stageInstanceEventUpdateEventHandler(v)
case func(*Session, *ThreadCreate):
return threadCreateEventHandler(v)
case func(*Session, *ThreadDelete):
@@ -1267,12 +1365,6 @@ func handlerForInterface(handler interface{}) EventHandler {
return threadUpdateEventHandler(v)
case func(*Session, *TypingStart):
return typingStartEventHandler(v)
- case func(*Session, *UserGuildSettingsUpdate):
- return userGuildSettingsUpdateEventHandler(v)
- case func(*Session, *UserNoteUpdate):
- return userNoteUpdateEventHandler(v)
- case func(*Session, *UserSettingsUpdate):
- return userSettingsUpdateEventHandler(v)
case func(*Session, *UserUpdate):
return userUpdateEventHandler(v)
case func(*Session, *VoiceServerUpdate):
@@ -1287,6 +1379,11 @@ func handlerForInterface(handler interface{}) EventHandler {
}
func init() {
+ registerInterfaceProvider(applicationCommandPermissionsUpdateEventHandler(nil))
+ registerInterfaceProvider(autoModerationActionExecutionEventHandler(nil))
+ registerInterfaceProvider(autoModerationRuleCreateEventHandler(nil))
+ registerInterfaceProvider(autoModerationRuleDeleteEventHandler(nil))
+ registerInterfaceProvider(autoModerationRuleUpdateEventHandler(nil))
registerInterfaceProvider(channelCreateEventHandler(nil))
registerInterfaceProvider(channelDeleteEventHandler(nil))
registerInterfaceProvider(channelPinsUpdateEventHandler(nil))
@@ -1297,9 +1394,6 @@ func init() {
registerInterfaceProvider(guildDeleteEventHandler(nil))
registerInterfaceProvider(guildEmojisUpdateEventHandler(nil))
registerInterfaceProvider(guildIntegrationsUpdateEventHandler(nil))
- registerInterfaceProvider(guildScheduledEventCreateEventHandler(nil))
- registerInterfaceProvider(guildScheduledEventUpdateEventHandler(nil))
- registerInterfaceProvider(guildScheduledEventDeleteEventHandler(nil))
registerInterfaceProvider(guildMemberAddEventHandler(nil))
registerInterfaceProvider(guildMemberRemoveEventHandler(nil))
registerInterfaceProvider(guildMemberUpdateEventHandler(nil))
@@ -1307,11 +1401,15 @@ func init() {
registerInterfaceProvider(guildRoleCreateEventHandler(nil))
registerInterfaceProvider(guildRoleDeleteEventHandler(nil))
registerInterfaceProvider(guildRoleUpdateEventHandler(nil))
+ registerInterfaceProvider(guildScheduledEventCreateEventHandler(nil))
+ registerInterfaceProvider(guildScheduledEventDeleteEventHandler(nil))
+ registerInterfaceProvider(guildScheduledEventUpdateEventHandler(nil))
+ registerInterfaceProvider(guildScheduledEventUserAddEventHandler(nil))
+ registerInterfaceProvider(guildScheduledEventUserRemoveEventHandler(nil))
registerInterfaceProvider(guildUpdateEventHandler(nil))
registerInterfaceProvider(interactionCreateEventHandler(nil))
registerInterfaceProvider(inviteCreateEventHandler(nil))
registerInterfaceProvider(inviteDeleteEventHandler(nil))
- registerInterfaceProvider(messageAckEventHandler(nil))
registerInterfaceProvider(messageCreateEventHandler(nil))
registerInterfaceProvider(messageDeleteEventHandler(nil))
registerInterfaceProvider(messageDeleteBulkEventHandler(nil))
@@ -1322,9 +1420,10 @@ func init() {
registerInterfaceProvider(presenceUpdateEventHandler(nil))
registerInterfaceProvider(presencesReplaceEventHandler(nil))
registerInterfaceProvider(readyEventHandler(nil))
- registerInterfaceProvider(relationshipAddEventHandler(nil))
- registerInterfaceProvider(relationshipRemoveEventHandler(nil))
registerInterfaceProvider(resumedEventHandler(nil))
+ registerInterfaceProvider(stageInstanceEventCreateEventHandler(nil))
+ registerInterfaceProvider(stageInstanceEventDeleteEventHandler(nil))
+ registerInterfaceProvider(stageInstanceEventUpdateEventHandler(nil))
registerInterfaceProvider(threadCreateEventHandler(nil))
registerInterfaceProvider(threadDeleteEventHandler(nil))
registerInterfaceProvider(threadListSyncEventHandler(nil))
@@ -1332,9 +1431,6 @@ func init() {
registerInterfaceProvider(threadMembersUpdateEventHandler(nil))
registerInterfaceProvider(threadUpdateEventHandler(nil))
registerInterfaceProvider(typingStartEventHandler(nil))
- registerInterfaceProvider(userGuildSettingsUpdateEventHandler(nil))
- registerInterfaceProvider(userNoteUpdateEventHandler(nil))
- registerInterfaceProvider(userSettingsUpdateEventHandler(nil))
registerInterfaceProvider(userUpdateEventHandler(nil))
registerInterfaceProvider(voiceServerUpdateEventHandler(nil))
registerInterfaceProvider(voiceStateUpdateEventHandler(nil))
diff --git a/vendor/github.com/bwmarrin/discordgo/events.go b/vendor/github.com/bwmarrin/discordgo/events.go
index cc5d711..e5d83b9 100644
--- a/vendor/github.com/bwmarrin/discordgo/events.go
+++ b/vendor/github.com/bwmarrin/discordgo/events.go
@@ -36,19 +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"`
- ReadState []*ReadState `json:"read_state"`
- PrivateChannels []*Channel `json:"private_channels"`
- Guilds []*Guild `json:"guilds"`
+ Version int `json:"v"`
+ SessionID string `json:"session_id"`
+ User *User `json:"user"`
+ Guilds []*Guild `json:"guilds"`
+ PrivateChannels []*Channel `json:"private_channels"`
- // Undocumented fields
- Settings *Settings `json:"user_settings"`
- UserGuildSettings []*UserGuildSettings `json:"user_guild_settings"`
- Relationships []*Relationship `json:"relationships"`
- Presences []*Presence `json:"presences"`
- Notes map[string]string `json:"notes"`
+ // TODO: Application and Shard
}
// ChannelCreate is the data for a ChannelCreate event.
@@ -191,7 +185,9 @@ type GuildMembersChunk struct {
Members []*Member `json:"members"`
ChunkIndex int `json:"chunk_index"`
ChunkCount int `json:"chunk_count"`
+ NotFound []string `json:"not_found,omitempty"`
Presences []*Presence `json:"presences,omitempty"`
+ Nonce string `json:"nonce,omitempty"`
}
// GuildIntegrationsUpdate is the data for a GuildIntegrationsUpdate event.
@@ -199,6 +195,21 @@ type GuildIntegrationsUpdate struct {
GuildID string `json:"guild_id"`
}
+// StageInstanceEventCreate is the data for a StageInstanceEventCreate event.
+type StageInstanceEventCreate struct {
+ *StageInstance
+}
+
+// StageInstanceEventUpdate is the data for a StageInstanceEventUpdate event.
+type StageInstanceEventUpdate struct {
+ *StageInstance
+}
+
+// StageInstanceEventDelete is the data for a StageInstanceEventDelete event.
+type StageInstanceEventDelete struct {
+ *StageInstance
+}
+
// GuildScheduledEventCreate is the data for a GuildScheduledEventCreate event.
type GuildScheduledEventCreate struct {
*GuildScheduledEvent
@@ -214,10 +225,18 @@ type GuildScheduledEventDelete struct {
*GuildScheduledEvent
}
-// MessageAck is the data for a MessageAck event.
-type MessageAck struct {
- MessageID string `json:"message_id"`
- ChannelID string `json:"channel_id"`
+// GuildScheduledEventUserAdd is the data for a GuildScheduledEventUserAdd event.
+type GuildScheduledEventUserAdd struct {
+ GuildScheduledEventID string `json:"guild_scheduled_event_id"`
+ UserID string `json:"user_id"`
+ GuildID string `json:"guild_id"`
+}
+
+// GuildScheduledEventUserRemove is the data for a GuildScheduledEventUserRemove event.
+type GuildScheduledEventUserRemove struct {
+ GuildScheduledEventID string `json:"guild_scheduled_event_id"`
+ UserID string `json:"user_id"`
+ GuildID string `json:"guild_id"`
}
// MessageCreate is the data for a MessageCreate event.
@@ -283,16 +302,6 @@ type Resumed struct {
Trace []string `json:"_trace"`
}
-// RelationshipAdd is the data for a RelationshipAdd event.
-type RelationshipAdd struct {
- *Relationship
-}
-
-// RelationshipRemove is the data for a RelationshipRemove event.
-type RelationshipRemove struct {
- *Relationship
-}
-
// TypingStart is the data for a TypingStart event.
type TypingStart struct {
UserID string `json:"user_id"`
@@ -306,20 +315,6 @@ type UserUpdate struct {
*User
}
-// UserSettingsUpdate is the data for a UserSettingsUpdate event.
-type UserSettingsUpdate map[string]interface{}
-
-// UserGuildSettingsUpdate is the data for a UserGuildSettingsUpdate event.
-type UserGuildSettingsUpdate struct {
- *UserGuildSettings
-}
-
-// UserNoteUpdate is the data for a UserNoteUpdate event.
-type UserNoteUpdate struct {
- ID string `json:"id"`
- Note string `json:"note"`
-}
-
// VoiceServerUpdate is the data for a VoiceServerUpdate event.
type VoiceServerUpdate struct {
Token string `json:"token"`
@@ -370,3 +365,38 @@ type InviteDelete struct {
GuildID string `json:"guild_id"`
Code string `json:"code"`
}
+
+// ApplicationCommandPermissionsUpdate is the data for an ApplicationCommandPermissionsUpdate event
+type ApplicationCommandPermissionsUpdate struct {
+ *GuildApplicationCommandPermissions
+}
+
+// AutoModerationRuleCreate is the data for an AutoModerationRuleCreate event.
+type AutoModerationRuleCreate struct {
+ *AutoModerationRule
+}
+
+// AutoModerationRuleUpdate is the data for an AutoModerationRuleUpdate event.
+type AutoModerationRuleUpdate struct {
+ *AutoModerationRule
+}
+
+// AutoModerationRuleDelete is the data for an AutoModerationRuleDelete event.
+type AutoModerationRuleDelete struct {
+ *AutoModerationRule
+}
+
+// AutoModerationActionExecution is the data for an AutoModerationActionExecution event.
+type AutoModerationActionExecution struct {
+ GuildID string `json:"guild_id"`
+ Action AutoModerationAction `json:"action"`
+ RuleID string `json:"rule_id"`
+ RuleTriggerType AutoModerationRuleTriggerType `json:"rule_trigger_type"`
+ UserID string `json:"user_id"`
+ ChannelID string `json:"channel_id"`
+ MessageID string `json:"message_id"`
+ AlertSystemMessageID string `json:"alert_system_message_id"`
+ Content string `json:"content"`
+ MatchedKeyword string `json:"matched_keyword"`
+ MatchedContent string `json:"matched_content"`
+}
diff --git a/vendor/github.com/bwmarrin/discordgo/interactions.go b/vendor/github.com/bwmarrin/discordgo/interactions.go
index 0e5ae3c..61a4e99 100644
--- a/vendor/github.com/bwmarrin/discordgo/interactions.go
+++ b/vendor/github.com/bwmarrin/discordgo/interactions.go
@@ -9,6 +9,7 @@ import (
"io"
"io/ioutil"
"net/http"
+ "strconv"
"time"
)
@@ -32,15 +33,21 @@ const (
type ApplicationCommand struct {
ID string `json:"id,omitempty"`
ApplicationID string `json:"application_id,omitempty"`
+ GuildID string `json:"guild_id,omitempty"`
Version string `json:"version,omitempty"`
Type ApplicationCommandType `json:"type,omitempty"`
Name string `json:"name"`
- DefaultPermission *bool `json:"default_permission,omitempty"`
+ NameLocalizations *map[Locale]string `json:"name_localizations,omitempty"`
+ // NOTE: DefaultPermission will be soon deprecated. Use DefaultMemberPermissions and DMPermission instead.
+ DefaultPermission *bool `json:"default_permission,omitempty"`
+ DefaultMemberPermissions *int64 `json:"default_member_permissions,string,omitempty"`
+ DMPermission *bool `json:"dm_permission,omitempty"`
// NOTE: Chat commands only. Otherwise it mustn't be set.
- Description string `json:"description,omitempty"`
- Options []*ApplicationCommandOption `json:"options"`
+ Description string `json:"description,omitempty"`
+ DescriptionLocalizations *map[Locale]string `json:"description_localizations,omitempty"`
+ Options []*ApplicationCommandOption `json:"options"`
}
// ApplicationCommandOptionType indicates the type of a slash command's option.
@@ -91,9 +98,11 @@ func (t ApplicationCommandOptionType) String() string {
// ApplicationCommandOption represents an option/subcommand/subcommands group.
type ApplicationCommandOption struct {
- Type ApplicationCommandOptionType `json:"type"`
- Name string `json:"name"`
- Description string `json:"description,omitempty"`
+ Type ApplicationCommandOptionType `json:"type"`
+ Name string `json:"name"`
+ NameLocalizations map[Locale]string `json:"name_localizations,omitempty"`
+ Description string `json:"description,omitempty"`
+ DescriptionLocalizations map[Locale]string `json:"description_localizations,omitempty"`
// NOTE: This feature was on the API, but at some point developers decided to remove it.
// So I commented it, until it will be officially on the docs.
// Default bool `json:"default"`
@@ -109,12 +118,17 @@ type ApplicationCommandOption struct {
MinValue *float64 `json:"min_value,omitempty"`
// Maximum value of number/integer option.
MaxValue float64 `json:"max_value,omitempty"`
+ // Minimum length of string option.
+ MinLength *int `json:"min_length,omitempty"`
+ // Maximum length of string option.
+ MaxLength int `json:"max_length,omitempty"`
}
// ApplicationCommandOptionChoice represents a slash command option choice.
type ApplicationCommandOptionChoice struct {
- Name string `json:"name"`
- Value interface{} `json:"value"`
+ Name string `json:"name"`
+ NameLocalizations map[Locale]string `json:"name_localizations,omitempty"`
+ Value interface{} `json:"value"`
}
// ApplicationCommandPermissions represents a single user or role permission for a command.
@@ -124,6 +138,18 @@ type ApplicationCommandPermissions struct {
Permission bool `json:"permission"`
}
+// GuildAllChannelsID is a helper function which returns guild_id-1.
+// It is used in ApplicationCommandPermissions to target all the channels within a guild.
+func GuildAllChannelsID(guild string) (id string, err error) {
+ var v uint64
+ v, err = strconv.ParseUint(guild, 10, 64)
+ if err != nil {
+ return
+ }
+
+ return strconv.FormatUint(v-1, 10), nil
+}
+
// ApplicationCommandPermissionsList represents a list of ApplicationCommandPermissions, needed for serializing to JSON.
type ApplicationCommandPermissionsList struct {
Permissions []*ApplicationCommandPermissions `json:"permissions"`
@@ -142,8 +168,9 @@ type ApplicationCommandPermissionType uint8
// Application command permission types.
const (
- ApplicationCommandPermissionTypeRole ApplicationCommandPermissionType = 1
- ApplicationCommandPermissionTypeUser ApplicationCommandPermissionType = 2
+ ApplicationCommandPermissionTypeRole ApplicationCommandPermissionType = 1
+ ApplicationCommandPermissionTypeUser ApplicationCommandPermissionType = 2
+ ApplicationCommandPermissionTypeChannel ApplicationCommandPermissionType = 3
)
// InteractionType indicates the type of an interaction event.
@@ -175,6 +202,7 @@ func (t InteractionType) String() string {
// Interaction represents data of an interaction.
type Interaction struct {
ID string `json:"id"`
+ AppID string `json:"application_id"`
Type InteractionType `json:"type"`
Data InteractionData `json:"data"`
GuildID string `json:"guild_id"`
@@ -184,6 +212,9 @@ type Interaction struct {
// NOTE: this field is only filled when a button click triggered the interaction. Otherwise it will be nil.
Message *Message `json:"message"`
+ // Bitwise set of permissions the app or bot has within the channel the interaction was sent from
+ AppPermissions int64 `json:"app_permissions,string"`
+
// The member who invoked this interaction.
// NOTE: this field is only filled when the slash command was invoked in a guild;
// if it was invoked in a DM, the `User` field will be filled instead.
@@ -509,11 +540,13 @@ type InteractionResponseData struct {
TTS bool `json:"tts"`
Content string `json:"content"`
Components []MessageComponent `json:"components"`
- Embeds []*MessageEmbed `json:"embeds,omitempty"`
+ Embeds []*MessageEmbed `json:"embeds"`
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
- Flags uint64 `json:"flags,omitempty"`
Files []*File `json:"-"`
+ // NOTE: only MessageFlagsSuppressEmbeds and MessageFlagsEphemeral can be set.
+ Flags MessageFlags `json:"flags,omitempty"`
+
// NOTE: autocomplete interaction only.
Choices []*ApplicationCommandOptionChoice `json:"choices,omitempty"`
diff --git a/vendor/github.com/bwmarrin/discordgo/logging.go b/vendor/github.com/bwmarrin/discordgo/logging.go
index 41f0481..b798d3e 100644
--- a/vendor/github.com/bwmarrin/discordgo/logging.go
+++ b/vendor/github.com/bwmarrin/discordgo/logging.go
@@ -90,7 +90,7 @@ func (v *VoiceConnection) log(msgL int, format string, a ...interface{}) {
msglog(msgL, 2, format, a...)
}
-// printJSON is a helper function to display JSON data in a easy to read format.
+// printJSON is a helper function to display JSON data in an easy to read format.
/* NOT USED ATM
func printJSON(body []byte) {
var prettyJSON bytes.Buffer
diff --git a/vendor/github.com/bwmarrin/discordgo/message.go b/vendor/github.com/bwmarrin/discordgo/message.go
index eb2f496..1ba6e44 100644
--- a/vendor/github.com/bwmarrin/discordgo/message.go
+++ b/vendor/github.com/bwmarrin/discordgo/message.go
@@ -199,7 +199,9 @@ const (
MessageFlagsCrossPosted MessageFlags = 1 << 0
// MessageFlagsIsCrossPosted this message originated from a message in another channel (via Channel Following).
MessageFlagsIsCrossPosted MessageFlags = 1 << 1
- // MessageFlagsSupressEmbeds do not include any embeds when serializing this message.
+ // MessageFlagsSuppressEmbeds do not include any embeds when serializing this message.
+ MessageFlagsSuppressEmbeds MessageFlags = 1 << 2
+ // TODO: deprecated, remove when compatibility is not needed
MessageFlagsSupressEmbeds MessageFlags = 1 << 2
// MessageFlagsSourceMessageDeleted the source message for this crosspost has been deleted (via Channel Following).
MessageFlagsSourceMessageDeleted MessageFlags = 1 << 3
@@ -225,7 +227,7 @@ type File struct {
// MessageSend stores all parameters you can send with ChannelMessageSendComplex.
type MessageSend struct {
Content string `json:"content,omitempty"`
- Embeds []*MessageEmbed `json:"embeds,omitempty"`
+ Embeds []*MessageEmbed `json:"embeds"`
TTS bool `json:"tts"`
Components []MessageComponent `json:"components"`
Files []*File `json:"-"`
@@ -244,8 +246,9 @@ type MessageSend struct {
type MessageEdit struct {
Content *string `json:"content,omitempty"`
Components []MessageComponent `json:"components"`
- Embeds []*MessageEmbed `json:"embeds,omitempty"`
+ Embeds []*MessageEmbed `json:"embeds"`
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
+ Flags MessageFlags `json:"flags,omitempty"`
ID string
Channel string
@@ -318,6 +321,9 @@ type MessageAllowedMentions struct {
// A list of user IDs to allow. This cannot be used when specifying
// AllowedMentionTypeUsers in the Parse slice.
Users []string `json:"users,omitempty"`
+
+ // For replies, whether to mention the author of the message being replied to
+ RepliedUser bool `json:"replied_user"`
}
// A MessageAttachment stores data for message attachments.
@@ -342,7 +348,7 @@ type MessageEmbedFooter struct {
// MessageEmbedImage is a part of a MessageEmbed struct.
type MessageEmbedImage struct {
- URL string `json:"url,omitempty"`
+ URL string `json:"url"`
ProxyURL string `json:"proxy_url,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
@@ -350,7 +356,7 @@ type MessageEmbedImage struct {
// MessageEmbedThumbnail is a part of a MessageEmbed struct.
type MessageEmbedThumbnail struct {
- URL string `json:"url,omitempty"`
+ URL string `json:"url"`
ProxyURL string `json:"proxy_url,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
@@ -372,7 +378,7 @@ type MessageEmbedProvider struct {
// MessageEmbedAuthor is a part of a MessageEmbed struct.
type MessageEmbedAuthor struct {
URL string `json:"url,omitempty"`
- Name string `json:"name,omitempty"`
+ Name string `json:"name"`
IconURL string `json:"icon_url,omitempty"`
ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}
@@ -451,7 +457,7 @@ type MessageApplication struct {
// MessageReference contains reference data sent with crossposted messages
type MessageReference struct {
MessageID string `json:"message_id"`
- ChannelID string `json:"channel_id"`
+ ChannelID string `json:"channel_id,omitempty"`
GuildID string `json:"guild_id,omitempty"`
}
diff --git a/vendor/github.com/bwmarrin/discordgo/restapi.go b/vendor/github.com/bwmarrin/discordgo/restapi.go
index 41796fe..79af468 100644
--- a/vendor/github.com/bwmarrin/discordgo/restapi.go
+++ b/vendor/github.com/bwmarrin/discordgo/restapi.go
@@ -39,6 +39,59 @@ var (
ErrUnauthorized = errors.New("HTTP request was unauthorized. This could be because the provided token was not a bot token. Please add \"Bot \" to the start of your token. https://discord.com/developers/docs/reference#authentication-example-bot-token-authorization-header")
)
+var (
+ // Marshal defines function used to encode JSON payloads
+ Marshal func(v interface{}) ([]byte, error) = json.Marshal
+ // Unmarshal defines function used to decode JSON payloads
+ Unmarshal func(src []byte, v interface{}) error = json.Unmarshal
+)
+
+// RESTError stores error information about a request with a bad response code.
+// Message is not always present, there are cases where api calls can fail
+// without returning a json message.
+type RESTError struct {
+ Request *http.Request
+ Response *http.Response
+ ResponseBody []byte
+
+ Message *APIErrorMessage // Message may be nil.
+}
+
+// newRestError returns a new REST API error.
+func newRestError(req *http.Request, resp *http.Response, body []byte) *RESTError {
+ restErr := &RESTError{
+ Request: req,
+ Response: resp,
+ ResponseBody: body,
+ }
+
+ // Attempt to decode the error and assume no message was provided if it fails
+ var msg *APIErrorMessage
+ err := Unmarshal(body, &msg)
+ if err == nil {
+ restErr.Message = msg
+ }
+
+ return restErr
+}
+
+// Error returns a Rest API Error with its status code and body.
+func (r RESTError) Error() string {
+ return "HTTP " + r.Response.Status + ", " + string(r.ResponseBody)
+}
+
+// RateLimitError is returned when a request exceeds a rate limit
+// and ShouldRetryOnRateLimit is false. The request may be manually
+// retried after waiting the duration specified by RetryAfter.
+type RateLimitError struct {
+ *RateLimit
+}
+
+// Error returns a rate limit error with rate limited endpoint and retry time.
+func (e RateLimitError) Error() string {
+ return "Rate limit exceeded on " + e.URL + ", retry after " + e.RetryAfter.String()
+}
+
// 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])
@@ -48,7 +101,7 @@ func (s *Session) Request(method, urlStr string, data interface{}) (response []b
func (s *Session) RequestWithBucketID(method, urlStr string, data interface{}, bucketID string) (response []byte, err error) {
var body []byte
if data != nil {
- body, err = json.Marshal(data)
+ body, err = Marshal(data)
if err != nil {
return
}
@@ -108,7 +161,7 @@ func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b
}
defer func() {
err2 := resp.Body.Close()
- if err2 != nil {
+ if s.Debug && err2 != nil {
log.Println("error closing resp body")
}
}()
@@ -147,19 +200,24 @@ func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b
}
case 429: // TOO MANY REQUESTS - Rate limiting
rl := TooManyRequests{}
- err = json.Unmarshal(response, &rl)
+ err = Unmarshal(response, &rl)
if err != nil {
s.log(LogError, "rate limit unmarshal error, %s", err)
return
}
- s.log(LogInformational, "Rate Limiting %s, retry in %v", urlStr, rl.RetryAfter)
- s.handleEvent(rateLimitEventType, &RateLimit{TooManyRequests: &rl, URL: urlStr})
- time.Sleep(rl.RetryAfter)
- // we can make the above smarter
- // this method can cause longer delays than required
+ if s.ShouldRetryOnRateLimit {
+ s.log(LogInformational, "Rate Limiting %s, retry in %v", urlStr, rl.RetryAfter)
+ s.handleEvent(rateLimitEventType, &RateLimit{TooManyRequests: &rl, URL: urlStr})
+
+ time.Sleep(rl.RetryAfter)
+ // 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)
+ } else {
+ err = &RateLimitError{&RateLimit{TooManyRequests: &rl, URL: urlStr}}
+ }
case http.StatusUnauthorized:
if strings.Index(s.Token, "Bot ") != 0 {
s.log(LogInformational, ErrUnauthorized.Error())
@@ -174,7 +232,7 @@ func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b
}
func unmarshal(data []byte, v interface{}) error {
- err := json.Unmarshal(data, v)
+ err := Unmarshal(data, v)
if err != nil {
return fmt.Errorf("%w: %s", ErrJSONUnmarshal, err)
}
@@ -276,6 +334,18 @@ func (s *Session) UserChannelCreate(recipientID string) (st *Channel, err error)
return
}
+// 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))
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+}
+
// UserGuilds returns an array of UserGuild structures for all guilds.
// limit : The number guilds that can be returned. (max 100)
// beforeID : If provided all guilds returned will be before given ID.
@@ -438,6 +508,19 @@ func (s *Session) Guild(guildID string) (st *Guild, err error) {
return
}
+// 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) {
+
+ body, err := s.RequestWithBucketID("GET", EndpointGuild(guildID)+"?with_counts=true", nil, EndpointGuild(guildID))
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+}
+
// 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) {
@@ -470,7 +553,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) (st *Guild, err error) {
// Bounds checking for VerificationLevel, interval: [0, 4]
if g.VerificationLevel != nil {
@@ -481,7 +564,7 @@ func (s *Session) GuildEdit(guildID string, g GuildParams) (st *Guild, err error
}
}
- //Bounds checking for regions
+ // Bounds checking for regions
if g.Region != "" {
isValid := false
regions, _ := s.VoiceRegions()
@@ -530,12 +613,30 @@ func (s *Session) GuildLeave(guildID string) (err error) {
return
}
-// GuildBans returns an array of GuildBan structures for all bans of a
-// given guild.
-// guildID : The ID of a Guild.
-func (s *Session) GuildBans(guildID string) (st []*GuildBan, err error) {
+// 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) {
+ uri := EndpointGuildBans(guildID)
- body, err := s.RequestWithBucketID("GET", EndpointGuildBans(guildID), nil, EndpointGuildBans(guildID))
+ v := url.Values{}
+ if limit != 0 {
+ v.Set("limit", strconv.Itoa(limit))
+ }
+ if beforeID != "" {
+ v.Set("before", beforeID)
+ }
+ if afterID != "" {
+ v.Set("after", afterID)
+ }
+
+ if len(v) > 0 {
+ uri += "?" + v.Encode()
+ }
+
+ body, err := s.RequestWithBucketID("GET", uri, nil, EndpointGuildBans(guildID))
if err != nil {
return
}
@@ -631,6 +732,29 @@ func (s *Session) GuildMembers(guildID string, after string, limit int) (st []*M
return
}
+// GuildMembersSearch returns a list of guild member objects whose username or nickname starts with a provided string
+// 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) {
+
+ uri := EndpointGuildMembersSearch(guildID)
+
+ queryParams := url.Values{}
+ queryParams.Set("query", query)
+ if limit > 1 {
+ queryParams.Set("limit", strconv.Itoa(limit))
+ }
+
+ body, err := s.RequestWithBucketID("GET", uri+"?"+queryParams.Encode(), nil, uri)
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+}
+
// GuildMember returns a member of a guild.
// guildID : The ID of a Guild.
// userID : The ID of a User
@@ -648,22 +772,10 @@ func (s *Session) GuildMember(guildID, userID string) (st *Member, err error) {
}
// GuildMemberAdd force joins a user to the guild.
-// accessToken : Valid access_token for the user.
// guildID : The ID of a Guild.
// userID : The ID of a User.
-// nick : Value to set users nickname to
-// roles : A list of role ID's to set on the member.
-// mute : If the user is muted.
-// deaf : If the user is deafened.
-func (s *Session) GuildMemberAdd(accessToken, guildID, userID, nick string, roles []string, mute, deaf bool) (err error) {
-
- data := struct {
- AccessToken string `json:"access_token"`
- Nick string `json:"nick,omitempty"`
- Roles []string `json:"roles,omitempty"`
- Mute bool `json:"mute,omitempty"`
- Deaf bool `json:"deaf,omitempty"`
- }{accessToken, nick, roles, mute, deaf}
+// data : Parameters of the user to add.
+func (s *Session) GuildMemberAdd(guildID, userID string, data *GuildMemberAddParams) (err error) {
_, err = s.RequestWithBucketID("PUT", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
if err != nil {
@@ -696,20 +808,30 @@ func (s *Session) GuildMemberDeleteWithReason(guildID, userID, reason string) (e
return
}
-// GuildMemberEdit edits the roles of a member.
+// GuildMemberEdit edits and returns updated member.
// guildID : The ID of a Guild.
// userID : The ID of a User.
-// roles : A list of role ID's to set on the member.
-func (s *Session) GuildMemberEdit(guildID, userID string, roles []string) (err error) {
-
- data := struct {
- Roles []string `json:"roles"`
- }{roles}
+// data : Updated GuildMember data.
+func (s *Session) GuildMemberEdit(guildID, userID string, data *GuildMemberParams) (st *Member, err error) {
+ var body []byte
+ body, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
+ if err != nil {
+ return nil, err
+ }
- _, err = s.RequestWithBucketID("PATCH", EndpointGuildMember(guildID, userID), data, EndpointGuildMember(guildID, ""))
+ err = unmarshal(body, &st)
return
}
+// 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)
+}
+
// GuildMemberMove moves a guild member from one voice channel to another/none
// guildID : The ID of a Guild.
// userID : The ID of a User.
@@ -904,11 +1026,11 @@ func (s *Session) GuildRoles(guildID string) (st []*Role, err error) {
return // TODO return pointer
}
-// GuildRoleCreate returns a new Guild Role.
-// guildID: The ID of a Guild.
-func (s *Session) GuildRoleCreate(guildID string) (st *Role, err error) {
-
- body, err := s.RequestWithBucketID("POST", EndpointGuildRoles(guildID), nil, EndpointGuildRoles(guildID))
+// 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))
if err != nil {
return
}
@@ -918,30 +1040,17 @@ func (s *Session) GuildRoleCreate(guildID string) (st *Role, err error) {
return
}
-// GuildRoleEdit updates an existing Guild Role with new values
+// GuildRoleEdit updates an existing Guild Role and returns updated Role data.
// guildID : The ID of a Guild.
// roleID : The ID of a Role.
-// name : The name of the Role.
-// color : The color of the role (decimal, not hex).
-// hoist : Whether to display the role's users separately.
-// perm : The permissions for the role.
-// mention : Whether this role is mentionable
-func (s *Session) GuildRoleEdit(guildID, roleID, name string, color int, hoist bool, perm int64, mention bool) (st *Role, err error) {
+// data : Updated Role data.
+func (s *Session) GuildRoleEdit(guildID, roleID string, data *RoleParams) (st *Role, err error) {
// Prevent sending a color int that is too big.
- if color > 0xFFFFFF {
- err = fmt.Errorf("color value cannot be larger than 0xFFFFFF")
- return nil, err
+ if data.Color != nil && *data.Color > 0xFFFFFF {
+ return nil, fmt.Errorf("color value cannot be larger than 0xFFFFFF")
}
- data := struct {
- Name string `json:"name"` // The role's name (overwrites existing)
- Color int `json:"color"` // The color the role should have (as a decimal, not hex)
- Hoist bool `json:"hoist"` // Whether to display the role's users separately
- Permissions int64 `json:"permissions,string"` // The overall permissions number of the role (overwrites existing)
- Mentionable bool `json:"mentionable"` // Whether this role is mentionable
- }{name, color, hoist, perm, mention}
-
body, err := s.RequestWithBucketID("PATCH", EndpointGuildRole(guildID, roleID), data, EndpointGuildRole(guildID, ""))
if err != nil {
return
@@ -1159,12 +1268,10 @@ func (s *Session) GuildEmbed(guildID string) (st *GuildEmbed, err error) {
return
}
-// GuildEmbedEdit returns the embed for a Guild.
+// GuildEmbedEdit edits the embed of a Guild.
// guildID : The ID of a Guild.
-func (s *Session) GuildEmbedEdit(guildID string, enabled bool, channelID string) (err error) {
-
- data := GuildEmbed{enabled, channelID}
-
+// data : New GuildEmbed data.
+func (s *Session) GuildEmbedEdit(guildID string, data *GuildEmbed) (err error) {
_, err = s.RequestWithBucketID("PATCH", EndpointGuildEmbed(guildID), data, EndpointGuildEmbed(guildID))
return
}
@@ -1218,19 +1325,24 @@ func (s *Session) GuildEmojis(guildID string) (emoji []*Emoji, err error) {
return
}
-// GuildEmojiCreate creates a new emoji
-// guildID : The ID of a Guild.
-// name : The Name of the Emoji.
-// image : The base64 encoded emoji image, has to be smaller than 256KB.
-// roles : The roles for which this emoji will be whitelisted, can be nil.
-func (s *Session) GuildEmojiCreate(guildID, name, image string, roles []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) {
+ var body []byte
+ body, err = s.RequestWithBucketID("GET", EndpointGuildEmoji(guildID, emojiID), nil, EndpointGuildEmoji(guildID, emojiID))
+ if err != nil {
+ return
+ }
- data := struct {
- Name string `json:"name"`
- Image string `json:"image"`
- Roles []string `json:"roles,omitempty"`
- }{name, image, roles}
+ err = unmarshal(body, &emoji)
+ return
+}
+// 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))
if err != nil {
return
@@ -1240,18 +1352,11 @@ func (s *Session) GuildEmojiCreate(guildID, name, image string, roles []string)
return
}
-// GuildEmojiEdit modifies an emoji
+// GuildEmojiEdit modifies and returns updated Emoji.
// guildID : The ID of a Guild.
// emojiID : The ID of an Emoji.
-// name : The Name of the Emoji.
-// roles : The roles for which this emoji will be whitelisted, can be nil.
-func (s *Session) GuildEmojiEdit(guildID, emojiID, name string, roles []string) (emoji *Emoji, err error) {
-
- data := struct {
- Name string `json:"name"`
- Roles []string `json:"roles,omitempty"`
- }{name, roles}
-
+// 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))
if err != nil {
return
@@ -1317,16 +1422,9 @@ func (s *Session) GuildTemplates(guildID string) (st []*GuildTemplate, err error
}
// GuildTemplateCreate creates a template for the guild
-// guildID: The ID of the guild
-// name: The name of the template (1-100 characters)
-// description: The description for the template (0-120 characters)
-func (s *Session) GuildTemplateCreate(guildID, name, description string) (st *GuildTemplate) {
-
- data := struct {
- Name string `json:"name"`
- Description string `json:"description"`
- }{name, description}
-
+// 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))
if err != nil {
return
@@ -1346,16 +1444,10 @@ func (s *Session) GuildTemplateSync(guildID, templateCode string) (err error) {
}
// GuildTemplateEdit modifies the template's metadata
-// guildID: The ID of the guild
-// templateCode: The code of the template
-// name: The name of the template (1-100 characters)
-// description: The description for the template (0-120 characters)
-func (s *Session) GuildTemplateEdit(guildID, templateCode, name, description string) (st *GuildTemplate, err error) {
-
- data := struct {
- Name string `json:"name,omitempty"`
- Description string `json:"description,omitempty"`
- }{name, description}
+// 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) {
body, err := s.RequestWithBucketID("PATCH", EndpointGuildTemplateSync(guildID, templateCode), data, EndpointGuildTemplateSync(guildID, ""))
if err != nil {
@@ -1391,19 +1483,10 @@ func (s *Session) Channel(channelID string) (st *Channel, err error) {
return
}
-// ChannelEdit edits the given channel
-// channelID : The ID of a Channel
-// name : The new name to assign the channel.
-func (s *Session) ChannelEdit(channelID, name string) (*Channel, error) {
- return s.ChannelEditComplex(channelID, &ChannelEdit{
- Name: name,
- })
-}
-
-// ChannelEditComplex edits an existing channel, replacing the parameters entirely with ChannelEdit struct
-// channelID : The ID of a Channel
-// data : The channel struct to send
-func (s *Session) ChannelEditComplex(channelID string, data *ChannelEdit) (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))
if err != nil {
return
@@ -1411,6 +1494,15 @@ func (s *Session) ChannelEditComplex(channelID string, data *ChannelEdit) (st *C
err = unmarshal(body, &st)
return
+
+}
+
+// ChannelEditComplex edits an existing channel, replacing the parameters entirely with ChannelEdit struct
+// 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)
}
// ChannelDelete deletes the given channel
@@ -1588,6 +1680,28 @@ func (s *Session) ChannelMessageSendReply(channelID string, content string, refe
})
}
+// 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)
+}
+
+// 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) {
+ if reference == nil {
+ return nil, fmt.Errorf("reply attempted with nil message reference")
+ }
+ return s.ChannelMessageSendComplex(channelID, &MessageSend{
+ Embeds: embeds,
+ Reference: reference,
+ })
+}
+
// ChannelMessageEdit edits an existing message, replacing it entirely with
// the given content.
// channelID : The ID of a Channel
@@ -1851,6 +1965,37 @@ func (s *Session) InviteWithCounts(inviteID string) (st *Invite, err error) {
return
}
+// 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) {
+ endpoint := EndpointInvite(inviteID)
+ v := url.Values{}
+ if guildScheduledEventID != "" {
+ v.Set("guild_scheduled_event_id", guildScheduledEventID)
+ }
+ if withCounts {
+ v.Set("with_counts", "true")
+ }
+ if withExpiration {
+ v.Set("with_expiration", "true")
+ }
+
+ if len(v) != 0 {
+ endpoint += "?" + v.Encode()
+ }
+
+ body, err := s.RequestWithBucketID("GET", endpoint, nil, EndpointInvite(""))
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+}
+
// InviteDelete deletes an existing invite
// inviteID : the code of an invite
func (s *Session) InviteDelete(inviteID string) (st *Invite, err error) {
@@ -2158,7 +2303,7 @@ func (s *Session) WebhookMessage(webhookID, token, messageID string) (message *M
return
}
- err = json.Unmarshal(body, &message)
+ err = Unmarshal(body, &message)
return
}
@@ -2207,7 +2352,7 @@ func (s *Session) WebhookMessageDelete(webhookID, token, messageID string) (err
// MessageReactionAdd creates an emoji reaction to a message.
// channelID : The channel ID.
// messageID : The message ID.
-// emojiID : Either the unicode emoji for the reaction, or a guild emoji identifier.
+// 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 {
// emoji such as #⃣ need to have # escaped
@@ -2620,7 +2765,7 @@ func (s *Session) ApplicationCommands(appID, guildID string) (cmd []*Application
endpoint = EndpointApplicationGuildCommands(appID, guildID)
}
- body, err := s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ body, err := s.RequestWithBucketID("GET", endpoint+"?with_localizations=true", nil, "GET "+endpoint)
if err != nil {
return
}
@@ -2668,6 +2813,8 @@ func (s *Session) ApplicationCommandPermissions(appID, guildID, cmdID string) (p
// guildID : The guild ID containing the application command
// cmdID : The command ID to edit the permissions of
// 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) {
endpoint := EndpointApplicationCommandPermissions(appID, guildID, cmdID)
@@ -2679,6 +2826,8 @@ func (s *Session) ApplicationCommandPermissionsEdit(appID, guildID, cmdID string
// appID : The Application ID
// guildID : The guild ID to batch edit commands of
// 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) {
endpoint := EndpointApplicationCommandsGuildPermissions(appID, guildID)
@@ -2687,10 +2836,9 @@ func (s *Session) ApplicationCommandPermissionsBatchEdit(appID, guildID string,
}
// InteractionRespond creates the response to an interaction.
-// appID : The application ID.
// interaction : Interaction instance.
// resp : Response message data.
-func (s *Session) InteractionRespond(interaction *Interaction, resp *InteractionResponse) (err error) {
+func (s *Session) InteractionRespond(interaction *Interaction, resp *InteractionResponse) error {
endpoint := EndpointInteractionResponse(interaction.ID, interaction.Token)
if resp.Data != nil && len(resp.Data.Files) > 0 {
@@ -2700,32 +2848,30 @@ func (s *Session) InteractionRespond(interaction *Interaction, resp *Interaction
}
_, err = s.request("POST", endpoint, contentType, body, endpoint, 0)
- } else {
- _, err = s.RequestWithBucketID("POST", endpoint, *resp, endpoint)
+ return err
}
+
+ _, err := s.RequestWithBucketID("POST", endpoint, *resp, endpoint)
return err
}
// InteractionResponse gets the response to an interaction.
-// appID : The application ID.
// interaction : Interaction instance.
-func (s *Session) InteractionResponse(appID string, interaction *Interaction) (*Message, error) {
- return s.WebhookMessage(appID, interaction.Token, "@original")
+func (s *Session) InteractionResponse(interaction *Interaction) (*Message, error) {
+ return s.WebhookMessage(interaction.AppID, interaction.Token, "@original")
}
// InteractionResponseEdit edits the response to an interaction.
-// appID : The application ID.
// interaction : Interaction instance.
// newresp : Updated response message data.
-func (s *Session) InteractionResponseEdit(appID string, interaction *Interaction, newresp *WebhookEdit) (*Message, error) {
- return s.WebhookMessageEdit(appID, interaction.Token, "@original", newresp)
+func (s *Session) InteractionResponseEdit(interaction *Interaction, newresp *WebhookEdit) (*Message, error) {
+ return s.WebhookMessageEdit(interaction.AppID, interaction.Token, "@original", newresp)
}
// InteractionResponseDelete deletes the response to an interaction.
-// appID : The application ID.
// interaction : Interaction instance.
-func (s *Session) InteractionResponseDelete(appID string, interaction *Interaction) error {
- endpoint := EndpointInteractionResponseActions(appID, interaction.Token)
+func (s *Session) InteractionResponseDelete(interaction *Interaction) error {
+ endpoint := EndpointInteractionResponseActions(interaction.AppID, interaction.Token)
_, err := s.RequestWithBucketID("DELETE", endpoint, nil, endpoint)
@@ -2733,29 +2879,76 @@ func (s *Session) InteractionResponseDelete(appID string, interaction *Interacti
}
// FollowupMessageCreate creates the followup message for an interaction.
-// appID : The application ID.
// 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(appID string, interaction *Interaction, wait bool, data *WebhookParams) (*Message, error) {
- return s.WebhookExecute(appID, interaction.Token, wait, data)
+func (s *Session) FollowupMessageCreate(interaction *Interaction, wait bool, data *WebhookParams) (*Message, error) {
+ return s.WebhookExecute(interaction.AppID, interaction.Token, wait, data)
}
// FollowupMessageEdit edits a followup message of an interaction.
-// appID : The application ID.
// interaction : Interaction instance.
// messageID : The followup message ID.
// data : Data to update the message
-func (s *Session) FollowupMessageEdit(appID string, interaction *Interaction, messageID string, data *WebhookEdit) (*Message, error) {
- return s.WebhookMessageEdit(appID, interaction.Token, messageID, data)
+func (s *Session) FollowupMessageEdit(interaction *Interaction, messageID string, data *WebhookEdit) (*Message, error) {
+ return s.WebhookMessageEdit(interaction.AppID, interaction.Token, messageID, data)
}
// FollowupMessageDelete deletes a followup message of an interaction.
-// appID : The application ID.
// interaction : Interaction instance.
// messageID : The followup message ID.
-func (s *Session) FollowupMessageDelete(appID string, interaction *Interaction, messageID string) error {
- return s.WebhookMessageDelete(appID, interaction.Token, messageID)
+func (s *Session) FollowupMessageDelete(interaction *Interaction, messageID string) error {
+ return s.WebhookMessageDelete(interaction.AppID, interaction.Token, messageID)
+}
+
+// ------------------------------------------------------------------------------------------------
+// Functions specific to stage instances
+// ------------------------------------------------------------------------------------------------
+
+// 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)
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &si)
+ return
+}
+
+// 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))
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &si)
+ return
+}
+
+// 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) {
+
+ body, err := s.RequestWithBucketID("PATCH", EndpointStageInstance(channelID), data, EndpointStageInstance(channelID))
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &si)
+ return
+}
+
+// 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))
+ return
}
// ------------------------------------------------------------------------------------------------
@@ -2869,3 +3062,80 @@ func (s *Session) GuildScheduledEventUsers(guildID, eventID string, limit int, w
err = unmarshal(body, &st)
return
}
+
+// ----------------------------------------------------------------------
+// Functions specific to auto moderation
+// ----------------------------------------------------------------------
+
+// AutoModerationRules returns a list of auto moderation rules.
+// guildID : ID of the guild
+func (s *Session) AutoModerationRules(guildID string) (st []*AutoModerationRule, err error) {
+ endpoint := EndpointGuildAutoModerationRules(guildID)
+
+ var body []byte
+ body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+}
+
+// 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) {
+ endpoint := EndpointGuildAutoModerationRule(guildID, ruleID)
+
+ var body []byte
+ body, err = s.RequestWithBucketID("GET", endpoint, nil, endpoint)
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+}
+
+// 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) {
+ endpoint := EndpointGuildAutoModerationRules(guildID)
+
+ var body []byte
+ body, err = s.RequestWithBucketID("POST", endpoint, rule, endpoint)
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+}
+
+// AutoModerationRuleEdit edits and returns the updated auto moderation rule.
+// 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) {
+ endpoint := EndpointGuildAutoModerationRule(guildID, ruleID)
+
+ var body []byte
+ body, err = s.RequestWithBucketID("PATCH", endpoint, rule, endpoint)
+ if err != nil {
+ return
+ }
+
+ err = unmarshal(body, &st)
+ return
+}
+
+// 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) {
+ endpoint := EndpointGuildAutoModerationRule(guildID, ruleID)
+ _, err = s.RequestWithBucketID("DELETE", endpoint, nil, endpoint)
+ return
+}
diff --git a/vendor/github.com/bwmarrin/discordgo/state.go b/vendor/github.com/bwmarrin/discordgo/state.go
index e75be89..6404b71 100644
--- a/vendor/github.com/bwmarrin/discordgo/state.go
+++ b/vendor/github.com/bwmarrin/discordgo/state.go
@@ -7,7 +7,7 @@
// This file contains code related to state tracking. If enabled, state
// tracking will capture the initial READY packet and many other websocket
-// events and maintain an in-memory state of of guilds, channels, users, and
+// events and maintain an in-memory state of guilds, channels, users, and
// so forth. This information can be accessed through the Session.State struct.
package discordgo
@@ -661,18 +661,6 @@ func (s *State) ThreadMemberUpdate(mu *ThreadMemberUpdate) error {
return nil
}
-// GuildChannel gets a channel by ID from a guild.
-// This method is Deprecated, use Channel(channelID)
-func (s *State) GuildChannel(guildID, channelID string) (*Channel, error) {
- return s.Channel(channelID)
-}
-
-// PrivateChannel gets a private channel by ID.
-// This method is Deprecated, use Channel(channelID)
-func (s *State) PrivateChannel(channelID string) (*Channel, error) {
- return s.Channel(channelID)
-}
-
// Channel gets a channel by ID, it will look in all guilds and private channels.
func (s *State) Channel(channelID string) (*Channel, error) {
if s == nil {
@@ -979,8 +967,9 @@ func (s *State) OnInterface(se *Session, i interface{}) (err error) {
err = s.GuildRemove(t.Guild)
case *GuildMemberAdd:
+ var guild *Guild
// Updates the MemberCount of the guild.
- guild, err := s.Guild(t.Member.GuildID)
+ guild, err = s.Guild(t.Member.GuildID)
if err != nil {
return err
}
@@ -995,8 +984,9 @@ func (s *State) OnInterface(se *Session, i interface{}) (err error) {
err = s.MemberAdd(t.Member)
}
case *GuildMemberRemove:
+ var guild *Guild
// Updates the MemberCount of the guild.
- guild, err := s.Guild(t.Member.GuildID)
+ guild, err = s.Guild(t.Member.GuildID)
if err != nil {
return err
}
diff --git a/vendor/github.com/bwmarrin/discordgo/structs.go b/vendor/github.com/bwmarrin/discordgo/structs.go
index 3a92c9f..26f507a 100644
--- a/vendor/github.com/bwmarrin/discordgo/structs.go
+++ b/vendor/github.com/bwmarrin/discordgo/structs.go
@@ -43,6 +43,9 @@ type Session struct {
// Should the session reconnect the websocket on errors.
ShouldReconnectOnError bool
+ // Should the session retry requests when rate limited.
+ ShouldRetryOnRateLimit bool
+
// Identify is sent during initial handshake with the discord gateway.
// https://discord.com/developers/docs/topics/gateway#identify
Identify Identify
@@ -56,12 +59,12 @@ type Session struct {
ShardCount int
// Should state tracking be enabled.
- // State tracking is the best way for getting the the users
+ // State tracking is the best way for getting the users
// active guilds and the members of the guilds.
StateEnabled bool
// Whether or not to call event handlers synchronously.
- // e.g false = launch event handlers in their own goroutines.
+ // e.g. false = launch event handlers in their own goroutines.
SyncEvents bool
// Exposed but should not be modified by User.
@@ -72,7 +75,7 @@ type Session struct {
// Max number of REST API retries
MaxRestRetries int
- // Status stores the currect status of the websocket connection
+ // Status stores the current status of the websocket connection
// this is being tested, may stay, may go away.
status int32
@@ -92,6 +95,9 @@ type Session struct {
// The http client used for REST requests
Client *http.Client
+ // The dialer used for WebSocket connection
+ Dialer *websocket.Dialer
+
// The user agent used for REST APIs
UserAgent string
@@ -194,23 +200,8 @@ type IntegrationAccount struct {
// A VoiceRegion stores data for a specific voice region server.
type VoiceRegion struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Hostname string `json:"sample_hostname"`
- Port int `json:"sample_port"`
-}
-
-// A VoiceICE stores data for voice ICE servers.
-type VoiceICE struct {
- TTL string `json:"ttl"`
- Servers []*ICEServer `json:"servers"`
-}
-
-// A ICEServer stores data for a specific voice ICE server.
-type ICEServer struct {
- URL string `json:"url"`
- Username string `json:"username"`
- Credential string `json:"credential"`
+ ID string `json:"id"`
+ Name string `json:"name"`
}
// InviteTargetType indicates the type of target of an invite
@@ -219,8 +210,8 @@ type InviteTargetType uint8
// Invite target types
const (
- InviteTargetStream InviteTargetType = 1
- InviteTargetEmbeddedAppliction InviteTargetType = 2
+ InviteTargetStream InviteTargetType = 1
+ InviteTargetEmbeddedApplication InviteTargetType = 2
)
// A Invite stores all data related to a specific Discord Guild or Channel invite.
@@ -243,6 +234,8 @@ type Invite struct {
// will only be filled when using InviteWithCounts
ApproximatePresenceCount int `json:"approximate_presence_count"`
ApproximateMemberCount int `json:"approximate_member_count"`
+
+ ExpiresAt *time.Time `json:"expires_at"`
}
// ChannelType is the type of a Channel
@@ -260,6 +253,7 @@ const (
ChannelTypeGuildNewsThread ChannelType = 10
ChannelTypeGuildPublicThread ChannelType = 11
ChannelTypeGuildPrivateThread ChannelType = 12
+ ChannelTypeGuildStageVoice ChannelType = 13
)
// A Channel holds all data related to an individual Discord channel.
@@ -354,20 +348,20 @@ func (c *Channel) IsThread() bool {
type ChannelEdit struct {
Name string `json:"name,omitempty"`
Topic string `json:"topic,omitempty"`
- NSFW bool `json:"nsfw,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"`
+ RateLimitPerUser *int `json:"rate_limit_per_user,omitempty"`
// NOTE: threads only
- Archived bool `json:"archived,omitempty"`
- AutoArchiveDuration int `json:"auto_archive_duration,omitempty"`
- Locked bool `json:"locked,bool"`
- Invitable bool `json:"invitable,omitempty"`
+ Archived *bool `json:"archived,omitempty"`
+ AutoArchiveDuration int `json:"auto_archive_duration,omitempty"`
+ Locked *bool `json:"locked,omitempty"`
+ Invitable *bool `json:"invitable,omitempty"`
}
// A ChannelFollow holds data returned after following a news channel
@@ -485,6 +479,17 @@ func (e *Emoji) APIName() string {
return e.ID
}
+// EmojiParams represents parameters needed to create or update an Emoji.
+type EmojiParams struct {
+ // Name of the emoji
+ Name string `json:"name,omitempty"`
+ // A base64 encoded emoji image, has to be smaller than 256KB.
+ // NOTE: can be only set on creation.
+ Image string `json:"image,omitempty"`
+ // Roles for which this emoji will be available.
+ Roles []string `json:"roles,omitempty"`
+}
+
// StickerFormat is the file format of the Sticker.
type StickerFormat int
@@ -552,6 +557,17 @@ const (
ExplicitContentFilterAllMembers ExplicitContentFilterLevel = 2
)
+// GuildNSFWLevel type definition
+type GuildNSFWLevel int
+
+// Constants for GuildNSFWLevel levels from 0 to 3 inclusive
+const (
+ GuildNSFWLevelDefault GuildNSFWLevel = 0
+ GuildNSFWLevelExplicit GuildNSFWLevel = 1
+ GuildNSFWLevelSafe GuildNSFWLevel = 2
+ GuildNSFWLevelAgeRestricted GuildNSFWLevel = 3
+)
+
// MfaLevel type definition
type MfaLevel int
@@ -675,8 +691,11 @@ type Guild struct {
// The explicit content filter level
ExplicitContentFilter ExplicitContentFilterLevel `json:"explicit_content_filter"`
+ // The NSFW Level of the guild
+ NSFWLevel GuildNSFWLevel `json:"nsfw_level"`
+
// The list of enabled guild features
- Features []string `json:"features"`
+ Features []GuildFeature `json:"features"`
// Required MFA level for the guild
MfaLevel MfaLevel `json:"mfa_level"`
@@ -731,6 +750,9 @@ type Guild struct {
// Permissions of our user
Permissions int64 `json:"permissions,string"`
+
+ // Stage instances in the guild
+ StageInstances []*StageInstance `json:"stage_instances"`
}
// A GuildPreview holds data related to a specific public Discord Guild, even if the user is not in the guild.
@@ -757,16 +779,31 @@ type GuildPreview struct {
// The list of enabled guild features
Features []string `json:"features"`
- // Approximate number of members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
+ // Approximate number of members in this guild
+ // NOTE: this field is only filled when using GuildWithCounts
ApproximateMemberCount int `json:"approximate_member_count"`
- // Approximate number of non-offline members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
+ // Approximate number of non-offline members in this guild
+ // NOTE: this field is only filled when using GuildWithCounts
ApproximatePresenceCount int `json:"approximate_presence_count"`
// the description for the guild
Description string `json:"description"`
}
+// 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)
+}
+
// GuildScheduledEvent is a representation of a scheduled event in a guild. Only for retrieval of the data.
// https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event
type GuildScheduledEvent struct {
@@ -842,7 +879,7 @@ func (p GuildScheduledEventParams) MarshalJSON() ([]byte, error) {
type guildScheduledEventParams GuildScheduledEventParams
if p.EntityType == GuildScheduledEventEntityTypeExternal && p.ChannelID == "" {
- return json.Marshal(struct {
+ return Marshal(struct {
guildScheduledEventParams
ChannelID json.RawMessage `json:"channel_id"`
}{
@@ -851,7 +888,7 @@ func (p GuildScheduledEventParams) MarshalJSON() ([]byte, error) {
})
}
- return json.Marshal(guildScheduledEventParams(p))
+ return Marshal(guildScheduledEventParams(p))
}
// GuildScheduledEventEntityMetadata holds additional metadata for guild scheduled event.
@@ -910,19 +947,19 @@ type GuildScheduledEventUser struct {
Member *Member `json:"member"`
}
-// A GuildTemplate represents
+// A GuildTemplate represents a replicable template for guild creation
type GuildTemplate struct {
// The unique code for the guild template
Code string `json:"code"`
// The name of the template
- Name string `json:"name"`
+ Name string `json:"name,omitempty"`
// The description for the template
- Description string `json:"description"`
+ Description *string `json:"description,omitempty"`
// The number of times this template has been used
- UsageCount string `json:"usage_count"`
+ UsageCount int `json:"usage_count"`
// The ID of the user who created the template
CreatorID string `json:"creator_id"`
@@ -946,6 +983,14 @@ type GuildTemplate struct {
IsDirty bool `json:"is_dirty"`
}
+// GuildTemplateParams stores the data needed to create or update a GuildTemplate.
+type GuildTemplateParams struct {
+ // The name of the template (1-100 characters)
+ Name string `json:"name,omitempty"`
+ // The description of the template (0-120 characters)
+ Description string `json:"description,omitempty"`
+}
+
// MessageNotifications is the notification level for a guild
// https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
type MessageNotifications int
@@ -989,13 +1034,42 @@ func (g *Guild) BannerURL() string {
// A UserGuild holds a brief version of a Guild
type UserGuild struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Icon string `json:"icon"`
- Owner bool `json:"owner"`
- Permissions int64 `json:"permissions,string"`
+ ID string `json:"id"`
+ Name string `json:"name"`
+ Icon string `json:"icon"`
+ Owner bool `json:"owner"`
+ Permissions int64 `json:"permissions,string"`
+ Features []GuildFeature `json:"features"`
}
+// GuildFeature indicates the presence of a feature in a guild
+type GuildFeature string
+
+// Constants for GuildFeature
+const (
+ GuildFeatureAnimatedBanner GuildFeature = "ANIMATED_BANNER"
+ GuildFeatureAnimatedIcon GuildFeature = "ANIMATED_ICON"
+ GuildFeatureAutoModeration GuildFeature = "AUTO_MODERATION"
+ GuildFeatureBanner GuildFeature = "BANNER"
+ GuildFeatureCommunity GuildFeature = "COMMUNITY"
+ GuildFeatureDiscoverable GuildFeature = "DISCOVERABLE"
+ GuildFeatureFeaturable GuildFeature = "FEATURABLE"
+ GuildFeatureInviteSplash GuildFeature = "INVITE_SPLASH"
+ GuildFeatureMemberVerificationGateEnabled GuildFeature = "MEMBER_VERIFICATION_GATE_ENABLED"
+ GuildFeatureMonetizationEnabled GuildFeature = "MONETIZATION_ENABLED"
+ GuildFeatureMoreStickers GuildFeature = "MORE_STICKERS"
+ GuildFeatureNews GuildFeature = "NEWS"
+ GuildFeaturePartnered GuildFeature = "PARTNERED"
+ GuildFeaturePreviewEnabled GuildFeature = "PREVIEW_ENABLED"
+ GuildFeaturePrivateThreads GuildFeature = "PRIVATE_THREADS"
+ GuildFeatureRoleIcons GuildFeature = "ROLE_ICONS"
+ GuildFeatureTicketedEventsEnabled GuildFeature = "TICKETED_EVENTS_ENABLED"
+ GuildFeatureVanityURL GuildFeature = "VANITY_URL"
+ GuildFeatureVerified GuildFeature = "VERIFIED"
+ GuildFeatureVipRegions GuildFeature = "VIP_REGIONS"
+ GuildFeatureWelcomeScreenEnabled GuildFeature = "WELCOME_SCREEN_ENABLED"
+)
+
// A GuildParams stores all the data needed to update discord guild settings
type GuildParams struct {
Name string `json:"name,omitempty"`
@@ -1045,6 +1119,20 @@ func (r *Role) Mention() string {
return fmt.Sprintf("<@&%s>", r.ID)
}
+// RoleParams represents the parameters needed to create or update a Role
+type RoleParams struct {
+ // The role's name
+ Name string `json:"name,omitempty"`
+ // The color the role should have (as a decimal, not hex)
+ Color *int `json:"color,omitempty"`
+ // Whether to display the role's users separately
+ Hoist *bool `json:"hoist,omitempty"`
+ // The overall permissions number of the role
+ Permissions *int64 `json:"permissions,omitempty,string"`
+ // Whether this role is mentionable
+ Mentionable *bool `json:"mentionable,omitempty"`
+}
+
// Roles are a collection of Role
type Roles []*Role
@@ -1062,15 +1150,19 @@ func (r Roles) Swap(i, j int) {
// A VoiceState stores the voice states of Guilds
type VoiceState struct {
- UserID string `json:"user_id"`
- SessionID string `json:"session_id"`
- ChannelID string `json:"channel_id"`
- GuildID string `json:"guild_id"`
- Suppress bool `json:"suppress"`
- SelfMute bool `json:"self_mute"`
- SelfDeaf bool `json:"self_deaf"`
- Mute bool `json:"mute"`
- Deaf bool `json:"deaf"`
+ GuildID string `json:"guild_id"`
+ ChannelID string `json:"channel_id"`
+ UserID string `json:"user_id"`
+ Member *Member `json:"member"`
+ SessionID string `json:"session_id"`
+ Deaf bool `json:"deaf"`
+ Mute bool `json:"mute"`
+ SelfDeaf bool `json:"self_deaf"`
+ SelfMute bool `json:"self_mute"`
+ SelfStream bool `json:"self_stream"`
+ SelfVideo bool `json:"self_video"`
+ Suppress bool `json:"suppress"`
+ RequestToSpeakTimestamp *time.Time `json:"request_to_speak_timestamp"`
}
// A Presence stores the online, offline, or idle and game status of Guild members.
@@ -1093,7 +1185,7 @@ func (t *TimeStamps) UnmarshalJSON(b []byte) error {
End float64 `json:"end,omitempty"`
Start float64 `json:"start,omitempty"`
}{}
- err := json.Unmarshal(b, &temp)
+ err := Unmarshal(b, &temp)
if err != nil {
return err
}
@@ -1170,25 +1262,6 @@ func (m *Member) AvatarURL(size string) string {
}
-// A Settings stores data for a specific users Discord client settings.
-type Settings struct {
- RenderEmbeds bool `json:"render_embeds"`
- InlineEmbedMedia bool `json:"inline_embed_media"`
- InlineAttachmentMedia bool `json:"inline_attachment_media"`
- EnableTTSCommand bool `json:"enable_tts_command"`
- MessageDisplayCompact bool `json:"message_display_compact"`
- ShowCurrentGame bool `json:"show_current_game"`
- ConvertEmoticons bool `json:"convert_emoticons"`
- Locale string `json:"locale"`
- Theme string `json:"theme"`
- GuildPositions []string `json:"guild_positions"`
- RestrictedGuilds []string `json:"restricted_guilds"`
- FriendSourceFlags *FriendSourceFlags `json:"friend_source_flags"`
- Status Status `json:"status"`
- DetectPlatformAccounts bool `json:"detect_platform_accounts"`
- DeveloperMode bool `json:"developer_mode"`
-}
-
// Status type definition
type Status string
@@ -1201,20 +1274,6 @@ const (
StatusOffline Status = "offline"
)
-// FriendSourceFlags stores ... TODO :)
-type FriendSourceFlags struct {
- All bool `json:"all"`
- MutualGuilds bool `json:"mutual_guilds"`
- MutualFriends bool `json:"mutual_friends"`
-}
-
-// A Relationship between the logged in user and Relationship.User
-type Relationship struct {
- User *User `json:"user"`
- Type int `json:"type"` // 1 = friend, 2 = blocked, 3 = incoming friend req, 4 = sent friend req
- ID string `json:"id"`
-}
-
// A TooManyRequests struct holds information received from Discord
// when receiving a HTTP 429 response.
type TooManyRequests struct {
@@ -1231,7 +1290,7 @@ func (t *TooManyRequests) UnmarshalJSON(b []byte) error {
Message string `json:"message"`
RetryAfter float64 `json:"retry_after"`
}{}
- err := json.Unmarshal(b, &u)
+ err := Unmarshal(b, &u)
if err != nil {
return err
}
@@ -1250,11 +1309,6 @@ type ReadState struct {
ID string `json:"id"`
}
-// An Ack is used to ack messages
-type Ack struct {
- Token string `json:"token"`
-}
-
// A GuildRole stores data for guild roles.
type GuildRole struct {
Role *Role `json:"role"`
@@ -1267,10 +1321,92 @@ type GuildBan struct {
User *User `json:"user"`
}
+// AutoModerationRule stores data for an auto moderation rule.
+type AutoModerationRule struct {
+ ID string `json:"id,omitempty"`
+ GuildID string `json:"guild_id,omitempty"`
+ Name string `json:"name,omitempty"`
+ CreatorID string `json:"creator_id,omitempty"`
+ EventType AutoModerationRuleEventType `json:"event_type,omitempty"`
+ TriggerType AutoModerationRuleTriggerType `json:"trigger_type,omitempty"`
+ TriggerMetadata *AutoModerationTriggerMetadata `json:"trigger_metadata,omitempty"`
+ Actions []AutoModerationAction `json:"actions,omitempty"`
+ Enabled *bool `json:"enabled,omitempty"`
+ ExemptRoles *[]string `json:"exempt_roles,omitempty"`
+ ExemptChannels *[]string `json:"exempt_channels,omitempty"`
+}
+
+// AutoModerationRuleEventType indicates in what event context a rule should be checked.
+type AutoModerationRuleEventType int
+
+// Auto moderation rule event types.
+const (
+ // AutoModerationEventMessageSend is checked when a member sends or edits a message in the guild
+ AutoModerationEventMessageSend AutoModerationRuleEventType = 1
+)
+
+// AutoModerationRuleTriggerType represents the type of content which can trigger the rule.
+type AutoModerationRuleTriggerType int
+
+// Auto moderation rule trigger types.
+const (
+ AutoModerationEventTriggerKeyword AutoModerationRuleTriggerType = 1
+ AutoModerationEventTriggerHarmfulLink AutoModerationRuleTriggerType = 2
+ AutoModerationEventTriggerSpam AutoModerationRuleTriggerType = 3
+ AutoModerationEventTriggerKeywordPreset AutoModerationRuleTriggerType = 4
+)
+
+// AutoModerationKeywordPreset represents an internally pre-defined wordset.
+type AutoModerationKeywordPreset uint
+
+// Auto moderation keyword presets.
+const (
+ AutoModerationKeywordPresetProfanity AutoModerationKeywordPreset = 1
+ AutoModerationKeywordPresetSexualContent AutoModerationKeywordPreset = 2
+ AutoModerationKeywordPresetSlurs AutoModerationKeywordPreset = 3
+)
+
+// AutoModerationTriggerMetadata represents additional metadata used to determine whether rule should be triggered.
+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"`
+ // 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"`
+}
+
+// AutoModerationActionType represents an action which will execute whenever a rule is triggered.
+type AutoModerationActionType int
+
+// Auto moderation actions types.
+const (
+ AutoModerationRuleActionBlockMessage AutoModerationActionType = 1
+ AutoModerationRuleActionSendAlertMessage AutoModerationActionType = 2
+ AutoModerationRuleActionTimeout AutoModerationActionType = 3
+)
+
+// AutoModerationActionMetadata represents additional metadata needed during execution for a specific action type.
+type AutoModerationActionMetadata struct {
+ // Channel to which user content should be logged.
+ // NOTE: should be only used with send alert message action type.
+ ChannelID string `json:"channel_id,omitempty"`
+
+ // Timeout duration in seconds (maximum of 2419200 - 4 weeks).
+ // NOTE: should be only used with timeout action type.
+ Duration int `json:"duration_seconds,omitempty"`
+}
+
+// AutoModerationAction stores data for an auto moderation action.
+type AutoModerationAction struct {
+ Type AutoModerationActionType `json:"type"`
+ Metadata *AutoModerationActionMetadata `json:"metadata,omitempty"`
+}
+
// A GuildEmbed stores data for a guild embed.
type GuildEmbed struct {
- Enabled bool `json:"enabled"`
- ChannelID string `json:"channel_id"`
+ Enabled *bool `json:"enabled,omitempty"`
+ ChannelID string `json:"channel_id,omitempty"`
}
// A GuildAuditLog stores data for a guild audit log.
@@ -1538,32 +1674,79 @@ const (
AuditLogActionThreadCreate AuditLogAction = 110
AuditLogActionThreadUpdate AuditLogAction = 111
AuditLogActionThreadDelete AuditLogAction = 112
+
+ AuditLogActionApplicationCommandPermissionUpdate AuditLogAction = 121
)
-// A UserGuildSettingsChannelOverride stores data for a channel override for a users guild settings.
-type UserGuildSettingsChannelOverride struct {
- Muted bool `json:"muted"`
- MessageNotifications int `json:"message_notifications"`
- ChannelID string `json:"channel_id"`
-}
+// GuildMemberParams stores data needed to update a member
+// https://discord.com/developers/docs/resources/guild#modify-guild-member
+type GuildMemberParams struct {
+ // Value to set user's nickname to.
+ Nick string `json:"nick,omitempty"`
+ // Array of role ids the member is assigned.
+ Roles *[]string `json:"roles,omitempty"`
+ // ID of channel to move user to (if they are connected to voice).
+ // Set to "" to remove user from a voice channel.
+ ChannelID *string `json:"channel_id,omitempty"`
+ // Whether the user is muted in voice channels.
+ Mute *bool `json:"mute,omitempty"`
+ // Whether the user is deafened in voice channels.
+ Deaf *bool `json:"deaf,omitempty"`
+ // When the user's timeout will expire and the user will be able
+ // to communicate in the guild again (up to 28 days in the future).
+ // Set to time.Time{} to remove timeout.
+ CommunicationDisabledUntil *time.Time `json:"communication_disabled_until,omitempty"`
+}
+
+// MarshalJSON is a helper function to marshal GuildMemberParams.
+func (p GuildMemberParams) MarshalJSON() (res []byte, err error) {
+ type guildMemberParams GuildMemberParams
+ v := struct {
+ guildMemberParams
+ ChannelID json.RawMessage `json:"channel_id,omitempty"`
+ CommunicationDisabledUntil json.RawMessage `json:"communication_disabled_until,omitempty"`
+ }{guildMemberParams: guildMemberParams(p)}
+
+ if p.ChannelID != nil {
+ if *p.ChannelID == "" {
+ v.ChannelID = json.RawMessage(`null`)
+ } else {
+ res, err = json.Marshal(p.ChannelID)
+ if err != nil {
+ return
+ }
+ v.ChannelID = res
+ }
+ }
+
+ if p.CommunicationDisabledUntil != nil {
+ if p.CommunicationDisabledUntil.IsZero() {
+ v.CommunicationDisabledUntil = json.RawMessage(`null`)
+ } else {
+ res, err = json.Marshal(p.CommunicationDisabledUntil)
+ if err != nil {
+ return
+ }
+ v.CommunicationDisabledUntil = res
+ }
+ }
-// A UserGuildSettings stores data for a users guild settings.
-type UserGuildSettings struct {
- SupressEveryone bool `json:"suppress_everyone"`
- Muted bool `json:"muted"`
- MobilePush bool `json:"mobile_push"`
- MessageNotifications int `json:"message_notifications"`
- GuildID string `json:"guild_id"`
- ChannelOverrides []*UserGuildSettingsChannelOverride `json:"channel_overrides"`
+ return json.Marshal(v)
}
-// A UserGuildSettingsEdit stores data for editing UserGuildSettings
-type UserGuildSettingsEdit struct {
- SupressEveryone bool `json:"suppress_everyone"`
- Muted bool `json:"muted"`
- MobilePush bool `json:"mobile_push"`
- MessageNotifications int `json:"message_notifications"`
- ChannelOverrides map[string]*UserGuildSettingsChannelOverride `json:"channel_overrides"`
+// GuildMemberAddParams stores data needed to add a user to a guild.
+// NOTE: All fields are optional, except AccessToken.
+type GuildMemberAddParams struct {
+ // Valid access_token for the user.
+ AccessToken string `json:"access_token"`
+ // Value to set users nickname to.
+ Nick string `json:"nick,omitempty"`
+ // A list of role ID's to set on the member.
+ Roles []string `json:"roles,omitempty"`
+ // Whether the user is muted.
+ Mute bool `json:"mute,omitempty"`
+ // Whether the user is deafened.
+ Deaf bool `json:"deaf,omitempty"`
}
// An APIErrorMessage is an api error message returned from discord
@@ -1642,7 +1825,7 @@ func (activity *Activity) UnmarshalJSON(b []byte) error {
Instance bool `json:"instance,omitempty"`
Flags int `json:"flags,omitempty"`
}{}
- err := json.Unmarshal(b, &temp)
+ err := Unmarshal(b, &temp)
if err != nil {
return err
}
@@ -1695,14 +1878,13 @@ const (
// Identify is sent during initial handshake with the discord gateway.
// https://discord.com/developers/docs/topics/gateway#identify
type Identify struct {
- Token string `json:"token"`
- Properties IdentifyProperties `json:"properties"`
- Compress bool `json:"compress"`
- LargeThreshold int `json:"large_threshold"`
- Shard *[2]int `json:"shard,omitempty"`
- Presence GatewayStatusUpdate `json:"presence,omitempty"`
- GuildSubscriptions bool `json:"guild_subscriptions"`
- Intents Intent `json:"intents"`
+ Token string `json:"token"`
+ Properties IdentifyProperties `json:"properties"`
+ Compress bool `json:"compress"`
+ LargeThreshold int `json:"large_threshold"`
+ Shard *[2]int `json:"shard,omitempty"`
+ Presence GatewayStatusUpdate `json:"presence,omitempty"`
+ Intents Intent `json:"intents"`
}
// IdentifyProperties contains the "properties" portion of an Identify packet
@@ -1715,6 +1897,49 @@ type IdentifyProperties struct {
ReferringDomain string `json:"$referring_domain"`
}
+// StageInstance holds information about a live stage.
+// https://discord.com/developers/docs/resources/stage-instance#stage-instance-resource
+type StageInstance struct {
+ // The id of this Stage instance
+ ID string `json:"id"`
+ // The guild id of the associated Stage channel
+ GuildID string `json:"guild_id"`
+ // The id of the associated Stage channel
+ ChannelID string `json:"channel_id"`
+ // The topic of the Stage instance (1-120 characters)
+ Topic string `json:"topic"`
+ // The privacy level of the Stage instance
+ // https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level
+ PrivacyLevel StageInstancePrivacyLevel `json:"privacy_level"`
+ // Whether or not Stage Discovery is disabled (deprecated)
+ DiscoverableDisabled bool `json:"discoverable_disabled"`
+ // The id of the scheduled event for this Stage instance
+ GuildScheduledEventID string `json:"guild_scheduled_event_id"`
+}
+
+// StageInstanceParams represents the parameters needed to create or edit a stage instance
+type StageInstanceParams struct {
+ // ChannelID represents the id of the Stage channel
+ ChannelID string `json:"channel_id,omitempty"`
+ // Topic of the Stage instance (1-120 characters)
+ Topic string `json:"topic,omitempty"`
+ // PrivacyLevel of the Stage instance (default GUILD_ONLY)
+ PrivacyLevel StageInstancePrivacyLevel `json:"privacy_level,omitempty"`
+ // SendStartNotification will notify @everyone that a Stage instance has started
+ SendStartNotification bool `json:"send_start_notification,omitempty"`
+}
+
+// StageInstancePrivacyLevel represents the privacy level of a Stage instance
+// https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level
+type StageInstancePrivacyLevel int
+
+const (
+ // StageInstancePrivacyLevelPublic The Stage instance is visible publicly. (deprecated)
+ StageInstancePrivacyLevelPublic StageInstancePrivacyLevel = 1
+ // StageInstancePrivacyLevelGuildOnly The Stage instance is visible to only guild members.
+ StageInstancePrivacyLevelGuildOnly StageInstancePrivacyLevel = 2
+)
+
// Constants for the different bit offsets of text channel permissions
const (
// Deprecated: PermissionReadMessages has been replaced with PermissionViewChannel for text and voice channels
@@ -1731,6 +1956,7 @@ const (
PermissionManageThreads = 0x0000000400000000
PermissionCreatePublicThreads = 0x0000000800000000
PermissionCreatePrivateThreads = 0x0000001000000000
+ PermissionUseExternalStickers = 0x0000002000000000
PermissionSendMessagesInThreads = 0x0000004000000000
)
@@ -1745,6 +1971,7 @@ const (
PermissionVoiceMoveMembers = 0x0000000001000000
PermissionVoiceUseVAD = 0x0000000002000000
PermissionVoiceRequestToSpeak = 0x0000000100000000
+ PermissionUseActivities = 0x0000008000000000
)
// Constants for general management.
@@ -1754,6 +1981,7 @@ const (
PermissionManageRoles = 0x0000000010000000
PermissionManageWebhooks = 0x0000000020000000
PermissionManageEmojis = 0x0000000040000000
+ PermissionManageEvents = 0x0000000200000000
)
// Constants for the different bit offsets of general permissions
@@ -1969,23 +2197,25 @@ type Intent int
// Constants for the different bit offsets of intents
const (
- IntentGuilds Intent = 1 << 0
- IntentGuildMembers Intent = 1 << 1
- IntentGuildBans Intent = 1 << 2
- IntentGuildEmojis Intent = 1 << 3
- IntentGuildIntegrations Intent = 1 << 4
- IntentGuildWebhooks Intent = 1 << 5
- IntentGuildInvites Intent = 1 << 6
- IntentGuildVoiceStates Intent = 1 << 7
- IntentGuildPresences Intent = 1 << 8
- IntentGuildMessages Intent = 1 << 9
- IntentGuildMessageReactions Intent = 1 << 10
- IntentGuildMessageTyping Intent = 1 << 11
- IntentDirectMessages Intent = 1 << 12
- IntentDirectMessageReactions Intent = 1 << 13
- IntentDirectMessageTyping Intent = 1 << 14
- IntentMessageContent Intent = 1 << 15
- IntentGuildScheduledEvents Intent = 1 << 16
+ IntentGuilds Intent = 1 << 0
+ IntentGuildMembers Intent = 1 << 1
+ IntentGuildBans Intent = 1 << 2
+ IntentGuildEmojis Intent = 1 << 3
+ IntentGuildIntegrations Intent = 1 << 4
+ IntentGuildWebhooks Intent = 1 << 5
+ IntentGuildInvites Intent = 1 << 6
+ IntentGuildVoiceStates Intent = 1 << 7
+ IntentGuildPresences Intent = 1 << 8
+ IntentGuildMessages Intent = 1 << 9
+ IntentGuildMessageReactions Intent = 1 << 10
+ IntentGuildMessageTyping Intent = 1 << 11
+ IntentDirectMessages Intent = 1 << 12
+ IntentDirectMessageReactions Intent = 1 << 13
+ IntentDirectMessageTyping Intent = 1 << 14
+ IntentMessageContent Intent = 1 << 15
+ IntentGuildScheduledEvents Intent = 1 << 16
+ IntentAutoModerationConfiguration Intent = 1 << 20
+ IntentAutoModerationExecution Intent = 1 << 21
// TODO: remove when compatibility is not needed
@@ -2020,7 +2250,9 @@ const (
IntentDirectMessages |
IntentDirectMessageReactions |
IntentDirectMessageTyping |
- IntentGuildScheduledEvents
+ IntentGuildScheduledEvents |
+ IntentAutoModerationConfiguration |
+ IntentAutoModerationExecution
IntentsAll = IntentsAllWithoutPrivileged |
IntentGuildMembers |
diff --git a/vendor/github.com/bwmarrin/discordgo/types.go b/vendor/github.com/bwmarrin/discordgo/types.go
deleted file mode 100644
index 7f969ae..0000000
--- a/vendor/github.com/bwmarrin/discordgo/types.go
+++ /dev/null
@@ -1,47 +0,0 @@
-// Discordgo - Discord bindings for Go
-// Available at https://github.com/bwmarrin/discordgo
-
-// Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// This file contains custom types, currently only a timestamp wrapper.
-
-package discordgo
-
-import (
- "encoding/json"
- "net/http"
-)
-
-// RESTError stores error information about a request with a bad response code.
-// Message is not always present, there are cases where api calls can fail
-// without returning a json message.
-type RESTError struct {
- Request *http.Request
- Response *http.Response
- ResponseBody []byte
-
- Message *APIErrorMessage // Message may be nil.
-}
-
-func newRestError(req *http.Request, resp *http.Response, body []byte) *RESTError {
- restErr := &RESTError{
- Request: req,
- Response: resp,
- ResponseBody: body,
- }
-
- // Attempt to decode the error and assume no message was provided if it fails
- var msg *APIErrorMessage
- err := json.Unmarshal(body, &msg)
- if err == nil {
- restErr.Message = msg
- }
-
- return restErr
-}
-
-func (r RESTError) Error() string {
- return "HTTP " + r.Response.Status + ", " + string(r.ResponseBody)
-}
diff --git a/vendor/github.com/bwmarrin/discordgo/util.go b/vendor/github.com/bwmarrin/discordgo/util.go
index 6231303..86f43b5 100644
--- a/vendor/github.com/bwmarrin/discordgo/util.go
+++ b/vendor/github.com/bwmarrin/discordgo/util.go
@@ -2,7 +2,6 @@ package discordgo
import (
"bytes"
- "encoding/json"
"fmt"
"io"
"mime/multipart"
@@ -30,7 +29,7 @@ func MultipartBodyWithJSON(data interface{}, files []*File) (requestContentType
body := &bytes.Buffer{}
bodywriter := multipart.NewWriter(body)
- payload, err := json.Marshal(data)
+ payload, err := Marshal(data)
if err != nil {
return
}
diff --git a/vendor/github.com/bwmarrin/discordgo/voice.go b/vendor/github.com/bwmarrin/discordgo/voice.go
index aedb879..efd8809 100644
--- a/vendor/github.com/bwmarrin/discordgo/voice.go
+++ b/vendor/github.com/bwmarrin/discordgo/voice.go
@@ -120,9 +120,9 @@ func (v *VoiceConnection) ChangeChannel(channelID string, mute, deaf bool) (err
v.log(LogInformational, "called")
data := voiceChannelJoinOp{4, voiceChannelJoinData{&v.GuildID, &channelID, mute, deaf}}
- v.wsMutex.Lock()
+ v.session.wsMutex.Lock()
err = v.session.wsConn.WriteJSON(data)
- v.wsMutex.Unlock()
+ v.session.wsMutex.Unlock()
if err != nil {
return
}
@@ -304,7 +304,7 @@ func (v *VoiceConnection) open() (err error) {
// Connect to VoiceConnection Websocket
vg := "wss://" + strings.TrimSuffix(v.endpoint, ":80")
v.log(LogInformational, "connecting to voice endpoint %s", vg)
- v.wsConn, _, err = websocket.DefaultDialer.Dial(vg, nil)
+ v.wsConn, _, err = v.session.Dialer.Dial(vg, nil)
if err != nil {
v.log(LogWarning, "error connecting to voice endpoint %s, %s", vg, err)
v.log(LogDebug, "voice struct: %#v\n", v)
@@ -323,7 +323,9 @@ func (v *VoiceConnection) open() (err error) {
}
data := voiceHandshakeOp{0, voiceHandshakeData{v.GuildID, v.UserID, v.sessionID, v.token}}
+ v.wsMutex.Lock()
err = v.wsConn.WriteJSON(data)
+ v.wsMutex.Unlock()
if err != nil {
v.log(LogWarning, "error sending init packet, %s", err)
return
@@ -829,7 +831,12 @@ func (v *VoiceConnection) opusReceiver(udpConn *net.UDPConn, close <-chan struct
p.SSRC = binary.BigEndian.Uint32(recvbuf[8:12])
// decrypt opus data
copy(nonce[:], recvbuf[0:12])
- p.Opus, _ = secretbox.Open(nil, recvbuf[12:rlen], &nonce, &v.op4.SecretKey)
+
+ if opus, ok := secretbox.Open(nil, recvbuf[12:rlen], &nonce, &v.op4.SecretKey); ok {
+ p.Opus = opus
+ } else {
+ return
+ }
// extension bit set, and not a RTCP packet
if ((recvbuf[0] & 0x10) == 0x10) && ((recvbuf[1] & 0x80) == 0) {
@@ -870,7 +877,11 @@ func (v *VoiceConnection) reconnect() {
v.reconnecting = true
v.Unlock()
- defer func() { v.reconnecting = false }()
+ defer func() {
+ v.Lock()
+ v.reconnecting = false
+ v.Unlock()
+ }()
// Close any currently open connections
v.Close()
diff --git a/vendor/github.com/bwmarrin/discordgo/webhook.go b/vendor/github.com/bwmarrin/discordgo/webhook.go
index f54a45c..9209b70 100644
--- a/vendor/github.com/bwmarrin/discordgo/webhook.go
+++ b/vendor/github.com/bwmarrin/discordgo/webhook.go
@@ -35,15 +35,16 @@ type WebhookParams struct {
Components []MessageComponent `json:"components"`
Embeds []*MessageEmbed `json:"embeds,omitempty"`
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
- // NOTE: Works only for followup messages.
- Flags uint64 `json:"flags,omitempty"`
+ // Only MessageFlagsSuppressEmbeds and MessageFlagsEphemeral can be set.
+ // MessageFlagsEphemeral can only be set when using Followup Message Create endpoint.
+ Flags MessageFlags `json:"flags,omitempty"`
}
// WebhookEdit stores data for editing of a webhook message.
type WebhookEdit struct {
- Content string `json:"content,omitempty"`
- Components []MessageComponent `json:"components"`
- Embeds []*MessageEmbed `json:"embeds,omitempty"`
+ Content *string `json:"content,omitempty"`
+ Components *[]MessageComponent `json:"components,omitempty"`
+ Embeds *[]*MessageEmbed `json:"embeds,omitempty"`
Files []*File `json:"-"`
AllowedMentions *MessageAllowedMentions `json:"allowed_mentions,omitempty"`
}
diff --git a/vendor/github.com/bwmarrin/discordgo/wsapi.go b/vendor/github.com/bwmarrin/discordgo/wsapi.go
index f2c228d..2579ee4 100644
--- a/vendor/github.com/bwmarrin/discordgo/wsapi.go
+++ b/vendor/github.com/bwmarrin/discordgo/wsapi.go
@@ -77,7 +77,7 @@ func (s *Session) Open() error {
s.log(LogInformational, "connecting to gateway %s", s.gateway)
header := http.Header{}
header.Add("accept-encoding", "zlib")
- s.wsConn, _, err = websocket.DefaultDialer.Dial(s.gateway, header)
+ s.wsConn, _, err = s.Dialer.Dial(s.gateway, header)
if err != nil {
s.log(LogError, "error connecting to gateway %s, %s", s.gateway, err)
s.gateway = "" // clear cached gateway
@@ -409,10 +409,13 @@ func (s *Session) UpdateStatusComplex(usd UpdateStatusData) (err error) {
}
type requestGuildMembersData struct {
- GuildIDs []string `json:"guild_id"`
- Query string `json:"query"`
- Limit int `json:"limit"`
- Presences bool `json:"presences"`
+ // TODO: Deprecated. Use string instead of []string
+ GuildIDs []string `json:"guild_id"`
+ Query *string `json:"query,omitempty"`
+ UserIDs *[]string `json:"user_ids,omitempty"`
+ Limit int `json:"limit"`
+ Nonce string `json:"nonce,omitempty"`
+ Presences bool `json:"presences"`
}
type requestGuildMembersOp struct {
@@ -425,29 +428,59 @@ type requestGuildMembersOp struct {
// guildID : Single Guild ID to request members of
// query : String that username starts with, leave empty to return all members
// limit : Max number of items to return, or 0 to request all members matched
+// nonce : Nonce to identify the Guild Members Chunk response
// presences : Whether to request presences of guild members
-func (s *Session) RequestGuildMembers(guildID string, query string, limit int, presences bool) (err error) {
+func (s *Session) RequestGuildMembers(guildID, query string, limit int, nonce string, presences bool) error {
+ return s.RequestGuildMembersBatch([]string{guildID}, query, limit, nonce, presences)
+}
+
+// RequestGuildMembersList requests guild members from the gateway
+// The gateway responds with GuildMembersChunk events
+// guildID : Single Guild ID to request members of
+// userIDs : IDs of users to fetch
+// limit : Max number of items to return, or 0 to request all members matched
+// nonce : Nonce to identify the Guild Members Chunk response
+// presences : Whether to request presences of guild members
+func (s *Session) RequestGuildMembersList(guildID string, userIDs []string, limit int, nonce string, presences bool) error {
+ return s.RequestGuildMembersBatchList([]string{guildID}, userIDs, limit, nonce, presences)
+}
+
+// RequestGuildMembersBatch requests guild members from the gateway
+// The gateway responds with GuildMembersChunk events
+// guildID : Slice of guild IDs to request members of
+// query : String that username starts with, leave empty to return all members
+// limit : Max number of items to return, or 0 to request all members matched
+// nonce : Nonce to identify the Guild Members Chunk response
+// presences : Whether to request presences of guild members
+//
+// NOTE: this function is deprecated, please use RequestGuildMembers instead
+func (s *Session) RequestGuildMembersBatch(guildIDs []string, query string, limit int, nonce string, presences bool) (err error) {
data := requestGuildMembersData{
- GuildIDs: []string{guildID},
- Query: query,
+ GuildIDs: guildIDs,
+ Query: &query,
Limit: limit,
+ Nonce: nonce,
Presences: presences,
}
err = s.requestGuildMembers(data)
return
}
-// RequestGuildMembersBatch requests guild members from the gateway
+// RequestGuildMembersBatchList requests guild members from the gateway
// The gateway responds with GuildMembersChunk events
// guildID : Slice of guild IDs to request members of
-// query : String that username starts with, leave empty to return all members
+// userIDs : IDs of users to fetch
// limit : Max number of items to return, or 0 to request all members matched
+// nonce : Nonce to identify the Guild Members Chunk response
// presences : Whether to request presences of guild members
-func (s *Session) RequestGuildMembersBatch(guildIDs []string, query string, limit int, presences bool) (err error) {
+//
+// NOTE: this function is deprecated, please use RequestGuildMembersList instead
+func (s *Session) RequestGuildMembersBatchList(guildIDs []string, userIDs []string, limit int, nonce string, presences bool) (err error) {
data := requestGuildMembersData{
GuildIDs: guildIDs,
- Query: query,
+ UserIDs: &userIDs,
Limit: limit,
+ Nonce: nonce,
Presences: presences,
}
err = s.requestGuildMembers(data)