1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-10-02 15:48:54 +00:00

State: remove redundant error return from NewFromSession

This commit is contained in:
mavolin 2020-12-15 16:40:08 +01:00 committed by diamondburned
parent 826b90a5f3
commit 7a7a56d613

View file

@ -110,7 +110,7 @@ func NewWithIntents(token string, intents ...gateway.Intents) (*State, error) {
return nil, err return nil, err
} }
return NewFromSession(s, defaultstore.New()) return NewFromSession(s, defaultstore.New()), nil
} }
func NewWithStore(token string, cabinet store.Cabinet) (*State, error) { func NewWithStore(token string, cabinet store.Cabinet) (*State, error) {
@ -119,12 +119,11 @@ func NewWithStore(token string, cabinet store.Cabinet) (*State, error) {
return nil, err return nil, err
} }
return NewFromSession(s, cabinet) return NewFromSession(s, cabinet), nil
} }
// NewFromSession never returns an error. This API is kept for backwards // NewFromSession creates a new State from the passed Session and Cabinet.
// compatibility. func NewFromSession(s *session.Session, cabinet store.Cabinet) *State {
func NewFromSession(s *session.Session, cabinet store.Cabinet) (*State, error) {
state := &State{ state := &State{
Session: s, Session: s,
Cabinet: cabinet, Cabinet: cabinet,
@ -137,7 +136,7 @@ func NewFromSession(s *session.Session, cabinet store.Cabinet) (*State, error) {
unreadyGuilds: moreatomic.NewGuildIDSet(), unreadyGuilds: moreatomic.NewGuildIDSet(),
} }
state.hookSession() state.hookSession()
return state, nil return state
} }
// WithContext returns a shallow copy of State with the context replaced in the // WithContext returns a shallow copy of State with the context replaced in the