From cd5d00a07eac0f353a8760519270f320630e1559 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Wed, 8 Jul 2020 02:06:47 -0700 Subject: [PATCH] Fixed typing events --- channel.go | 3 +++ go.mod | 4 ++-- go.sum | 6 ++++++ service.go | 8 ++++---- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/channel.go b/channel.go index a69c9fb..faae47a 100644 --- a/channel.go +++ b/channel.go @@ -201,6 +201,9 @@ func (ch *Channel) JoinServer(ctx context.Context, ct cchat.MessagesContainer) ( return NewBacklogMessage(m, ch.session, *g) } + // Subscribe to typing events. + ch.session.Members.Subscribe(ch.guildID) + // Listen to new members before creating the backlog and requesting members. addcancel(ch.session.AddHandler(func(c *gateway.GuildMembersChunkEvent) { if c.GuildID != ch.guildID { diff --git a/go.mod b/go.mod index 53cdde8..ef81479 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/diamondburned/cchat-discord go 1.14 require ( - github.com/diamondburned/arikawa v0.9.5 + github.com/diamondburned/arikawa v0.9.6 github.com/diamondburned/cchat v0.0.42 - github.com/diamondburned/ningen v0.1.1-0.20200621014632-6babb812b249 + github.com/diamondburned/ningen v0.1.1-0.20200708090333-227e90d19851 github.com/dustin/go-humanize v1.0.0 github.com/go-test/deep v1.0.6 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 9766a5d..2ae95fc 100644 --- a/go.sum +++ b/go.sum @@ -25,6 +25,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/diamondburned/arikawa v0.9.5 h1:P1ffsp+NHT22wWKYFVC8CdlGRLzPuUV9FcCBKOCJpCI= github.com/diamondburned/arikawa v0.9.5/go.mod h1:nIhVIatzTQhPUa7NB8w4koG1RF9gYbpAr8Fj8sKq660= +github.com/diamondburned/arikawa v0.9.6 h1:6TpfTKa2btoVQGxojNqv8g2YC0tIc/tX5w/OCVZPF5Q= +github.com/diamondburned/arikawa v0.9.6/go.mod h1:nIhVIatzTQhPUa7NB8w4koG1RF9gYbpAr8Fj8sKq660= github.com/diamondburned/cchat v0.0.34 h1:BGiVxMRA9dmW3rLilIldBvjVan7eTTpaWCCfX9IKBYU= github.com/diamondburned/cchat v0.0.34/go.mod h1:+zXktogE45A0om4fT6B/z6Ii7FXNafjxsNspI0rlhbU= github.com/diamondburned/cchat v0.0.35 h1:WiMGl8BQJgbP9E4xRxgLGlqUsHpTcJgDKDt8/6a7lBk= @@ -43,6 +45,10 @@ github.com/diamondburned/cchat v0.0.42 h1:FVMLy9hOTxKju8OWDBIStrekbgTHCaH8+GVnV4 github.com/diamondburned/cchat v0.0.42/go.mod h1:+zXktogE45A0om4fT6B/z6Ii7FXNafjxsNspI0rlhbU= github.com/diamondburned/ningen v0.1.1-0.20200621014632-6babb812b249 h1:yP7kJ+xCGpDz6XbcfACJcju4SH1XDPwlrvbofz3lP8I= github.com/diamondburned/ningen v0.1.1-0.20200621014632-6babb812b249/go.mod h1:xW9hpBZsGi8KpAh10TyP+YQlYBo+Xc+2w4TR6N0951A= +github.com/diamondburned/ningen v0.1.1-0.20200708085949-b64e350f3b8c h1:3h/kyk6HplYZF3zLi106itjYJWjbuMK/twijeGLEy2M= +github.com/diamondburned/ningen v0.1.1-0.20200708085949-b64e350f3b8c/go.mod h1:FNezDLQIhoDS+RkXLSQ7dJNrt6BW/nVl1krzDgWMQwg= +github.com/diamondburned/ningen v0.1.1-0.20200708090333-227e90d19851 h1:xf1aLPnwK/Yn2z7dBIgQROSVOEc2wtivgnnwBItdEVM= +github.com/diamondburned/ningen v0.1.1-0.20200708090333-227e90d19851/go.mod h1:FNezDLQIhoDS+RkXLSQ7dJNrt6BW/nVl1krzDgWMQwg= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= diff --git a/service.go b/service.go index 6b2b09f..01a21ea 100644 --- a/service.go +++ b/service.go @@ -84,10 +84,6 @@ func NewSessionToken(token string) (*Session, error) { return nil, err } - if err := s.Open(); err != nil { - return nil, err - } - return NewSession(s) } @@ -103,6 +99,10 @@ func NewSession(s *state.State) (*Session, error) { return nil, errors.Wrap(err, "Failed to create a state wrapper") } + if err := s.Open(); err != nil { + return nil, err + } + return &Session{ userID: u.ID, State: n,