diff --git a/bot/extras/middlewares/middlewares.go b/bot/extras/middlewares/middlewares.go index 7288b32..23ed738 100644 --- a/bot/extras/middlewares/middlewares.go +++ b/bot/extras/middlewares/middlewares.go @@ -29,7 +29,7 @@ func AdminOnly(ctx *bot.Context) func(interface{}) error { func GuildOnly(ctx *bot.Context) func(interface{}) error { return func(ev interface{}) error { - // Try and infer the GuildID. + // Try and infer the GuildIDs. if guildID := infer.GuildID(ev); guildID.IsValid() { return nil } diff --git a/bot/extras/middlewares/middlewares_test.go b/bot/extras/middlewares/middlewares_test.go index 780917f..46ebcfa 100644 --- a/bot/extras/middlewares/middlewares_test.go +++ b/bot/extras/middlewares/middlewares_test.go @@ -75,7 +75,7 @@ func TestGuildOnly(t *testing.T) { } var middleware = GuildOnly(ctx) - t.Run("allow message with GuildID", func(t *testing.T) { + t.Run("allow message with GuildIDs", func(t *testing.T) { var msg = &gateway.MessageCreateEvent{ Message: discord.Message{ ID: 3, diff --git a/gateway/gateway.go b/gateway/gateway.go index 792acd6..b10a9ed 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -95,15 +95,6 @@ type Gateway struct { // independently. WSTimeout time.Duration - // ReconnectTimeout is the timeout used during reconnection. - // If the a connection to the gateway can't be established before the - // duration passes, the Gateway will be closed and FatalErrorCallback will - // be called. - // - // Setting this to 0 is equivalent to no timeout. - // - // Deprecated: It is recommended to use ReconnectAttempts instead. - ReconnectTimeout time.Duration // ReconnectAttempts are the amount of attempts made to Reconnect, before // aborting. If this set to 0, unlimited attempts will be made. ReconnectAttempts uint @@ -262,29 +253,14 @@ func (g *Gateway) HasIntents(intents Intents) bool { } // Close closes the underlying Websocket connection, invalidating the session -// ID. A new gateway connection can be established, by calling Open again. +// ID. // -// If the wsutil.Connection of the Gateway's WS implements -// wsutil.GracefulCloser, such as the default one, Close will send a closing -// frame before ending the connection, closing it gracefully. This will cause -// the bot to appear as offline instantly. +// It will send a closing frame before ending the connection, closing it +// gracefully. This will cause the bot to appear as offline instantly. func (g *Gateway) Close() error { return g.close(true) } -// CloseGracefully attempts to close the gateway connection gracefully, by -// sending a closing frame before ending the connection. This will cause the -// gateway's session id to be rendered invalid. -// -// Note that a graceful closure is only possible, if the wsutil.Connection of -// the Gateway's Websocket implements wsutil.GracefulCloser. -// -// Deprecated: Close behaves identically to CloseGracefully, and should be used -// instead. -func (g *Gateway) CloseGracefully() error { - return g.Close() -} - // Pause pauses the Gateway connection, by ending the connection without // sending a closing frame. This allows the connection to be resumed at a later // point, by calling Reconnect or ReconnectCtx. @@ -342,19 +318,10 @@ func (g *Gateway) SessionID() string { return g.sessionID } -// Reconnect tries to reconnect to the Gateway until the ReconnectAttempts or -// ReconnectTimeout is reached. +// Reconnect tries to reconnect to the Gateway until the ReconnectAttempts are +// reached. func (g *Gateway) Reconnect() { - ctx := context.Background() - - if g.ReconnectTimeout > 0 { - var cancel func() - ctx, cancel = context.WithTimeout(context.Background(), g.ReconnectTimeout) - - defer cancel() - } - - g.ReconnectCtx(ctx) + g.ReconnectCtx(context.Background()) } // ReconnectCtx attempts to Reconnect until context expires. diff --git a/gateway/ready.go b/gateway/ready.go index 3cb537c..b6f13fc 100644 --- a/gateway/ready.go +++ b/gateway/ready.go @@ -247,7 +247,7 @@ func ConvertSupplementalMember(sm SupplementalMember) discord.Member { } // ConvertSupplementalPresence converts a SupplementalPresence to a regular -// Presence with an empty GuildID. +// Presence with an empty GuildIDs. func ConvertSupplementalPresence(sp SupplementalPresence) Presence { return Presence{ User: discord.User{ID: sp.UserID}, diff --git a/state/state.go b/state/state.go index 4f5da2c..b3b959c 100644 --- a/state/state.go +++ b/state/state.go @@ -625,7 +625,7 @@ func (s *State) Messages(channelID discord.ChannelID) ([]discord.Message, error) return nil, err } - // New messages fetched weirdly does not have GuildID filled. We'll try and + // New messages fetched weirdly does not have GuildIDs filled. We'll try and // get it for consistency with incoming message creates. var guildID discord.GuildID diff --git a/voice/voicegateway/commands.go b/voice/voicegateway/commands.go index 6dde406..f5cc70a 100644 --- a/voice/voicegateway/commands.go +++ b/voice/voicegateway/commands.go @@ -10,10 +10,10 @@ import ( var ( // ErrMissingForIdentify is an error when we are missing information to identify. - ErrMissingForIdentify = errors.New("missing GuildID, UserID, SessionID, or Token for identify") + ErrMissingForIdentify = errors.New("missing GuildIDs, UserID, SessionID, or Token for identify") // ErrMissingForResume is an error when we are missing information to resume. - ErrMissingForResume = errors.New("missing GuildID, SessionID, or Token for resuming") + ErrMissingForResume = errors.New("missing GuildIDs, SessionID, or Token for resuming") ) // OPCode 0