1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-11-30 16:17:57 +00:00

all: Remove deprecated symbols

This commit is contained in:
Maximilian von Lindern 2021-05-29 21:39:03 +02:00 committed by diamondburned
parent 5a1837a094
commit d2b70ebfa7
6 changed files with 12 additions and 45 deletions

View file

@ -29,7 +29,7 @@ func AdminOnly(ctx *bot.Context) func(interface{}) error {
func GuildOnly(ctx *bot.Context) func(interface{}) error { func GuildOnly(ctx *bot.Context) func(interface{}) error {
return func(ev interface{}) error { return func(ev interface{}) error {
// Try and infer the GuildID. // Try and infer the GuildIDs.
if guildID := infer.GuildID(ev); guildID.IsValid() { if guildID := infer.GuildID(ev); guildID.IsValid() {
return nil return nil
} }

View file

@ -75,7 +75,7 @@ func TestGuildOnly(t *testing.T) {
} }
var middleware = GuildOnly(ctx) 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{ var msg = &gateway.MessageCreateEvent{
Message: discord.Message{ Message: discord.Message{
ID: 3, ID: 3,

View file

@ -95,15 +95,6 @@ type Gateway struct {
// independently. // independently.
WSTimeout time.Duration 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 // ReconnectAttempts are the amount of attempts made to Reconnect, before
// aborting. If this set to 0, unlimited attempts will be made. // aborting. If this set to 0, unlimited attempts will be made.
ReconnectAttempts uint ReconnectAttempts uint
@ -262,29 +253,14 @@ func (g *Gateway) HasIntents(intents Intents) bool {
} }
// Close closes the underlying Websocket connection, invalidating the session // 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 // It will send a closing frame before ending the connection, closing it
// wsutil.GracefulCloser, such as the default one, Close will send a closing // gracefully. This will cause the bot to appear as offline instantly.
// frame before ending the connection, closing it gracefully. This will cause
// the bot to appear as offline instantly.
func (g *Gateway) Close() error { func (g *Gateway) Close() error {
return g.close(true) 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 // Pause pauses the Gateway connection, by ending the connection without
// sending a closing frame. This allows the connection to be resumed at a later // sending a closing frame. This allows the connection to be resumed at a later
// point, by calling Reconnect or ReconnectCtx. // point, by calling Reconnect or ReconnectCtx.
@ -342,19 +318,10 @@ func (g *Gateway) SessionID() string {
return g.sessionID return g.sessionID
} }
// Reconnect tries to reconnect to the Gateway until the ReconnectAttempts or // Reconnect tries to reconnect to the Gateway until the ReconnectAttempts are
// ReconnectTimeout is reached. // reached.
func (g *Gateway) Reconnect() { func (g *Gateway) Reconnect() {
ctx := context.Background() g.ReconnectCtx(context.Background())
if g.ReconnectTimeout > 0 {
var cancel func()
ctx, cancel = context.WithTimeout(context.Background(), g.ReconnectTimeout)
defer cancel()
}
g.ReconnectCtx(ctx)
} }
// ReconnectCtx attempts to Reconnect until context expires. // ReconnectCtx attempts to Reconnect until context expires.

View file

@ -247,7 +247,7 @@ func ConvertSupplementalMember(sm SupplementalMember) discord.Member {
} }
// ConvertSupplementalPresence converts a SupplementalPresence to a regular // ConvertSupplementalPresence converts a SupplementalPresence to a regular
// Presence with an empty GuildID. // Presence with an empty GuildIDs.
func ConvertSupplementalPresence(sp SupplementalPresence) Presence { func ConvertSupplementalPresence(sp SupplementalPresence) Presence {
return Presence{ return Presence{
User: discord.User{ID: sp.UserID}, User: discord.User{ID: sp.UserID},

View file

@ -625,7 +625,7 @@ func (s *State) Messages(channelID discord.ChannelID) ([]discord.Message, error)
return nil, err 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. // get it for consistency with incoming message creates.
var guildID discord.GuildID var guildID discord.GuildID

View file

@ -10,10 +10,10 @@ import (
var ( var (
// ErrMissingForIdentify is an error when we are missing information to identify. // 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 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 // OPCode 0