Assign to discordState directly from openState func
This commit is contained in:
parent
9d6326f0f1
commit
652083ad94
3 changed files with 9 additions and 15 deletions
|
|
@ -66,8 +66,7 @@ func (lf *LoginForm) onLoginButtonSelected() {
|
|||
mainFlex = newMainFlex()
|
||||
|
||||
// We got the token, return with a new Session.
|
||||
discordState, err = openState(l.Token)
|
||||
if err != nil {
|
||||
if err = openState(l.Token); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
|||
3
main.go
3
main.go
|
|
@ -67,8 +67,7 @@ func main() {
|
|||
} else {
|
||||
mainFlex = newMainFlex()
|
||||
|
||||
discordState, err = openState(token)
|
||||
if err != nil {
|
||||
if err = openState(token); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
|
|
|||
18
state.go
18
state.go
|
|
@ -27,22 +27,18 @@ type State struct {
|
|||
*state.State
|
||||
}
|
||||
|
||||
func openState(token string) (*State, error) {
|
||||
s := &State{
|
||||
func openState(token string) error {
|
||||
discordState = &State{
|
||||
State: state.New(token),
|
||||
}
|
||||
|
||||
// Handlers
|
||||
s.AddHandler(s.onReady)
|
||||
s.AddHandler(s.onMessageCreate)
|
||||
s.StateLog = s.onLog
|
||||
s.OnRequest = append(s.Client.OnRequest, s.onRequest)
|
||||
discordState.AddHandler(discordState.onReady)
|
||||
discordState.AddHandler(discordState.onMessageCreate)
|
||||
discordState.StateLog = discordState.onLog
|
||||
discordState.OnRequest = append(discordState.Client.OnRequest, discordState.onRequest)
|
||||
|
||||
if err := s.Open(context.TODO()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s, nil
|
||||
return discordState.Open(context.TODO())
|
||||
}
|
||||
|
||||
func (s *State) onLog(err error) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue