Commit graph

200 commits

Author SHA1 Message Date
Carson Hoffman
aba3c0c056
Allow resume on reconnect 2020-04-11 23:07:03 -04:00
Simon
e405cbd54c handle empty channel id in ChannelVoiceJoinManual (#672) 2019-07-21 21:02:54 -07:00
Christopher Felegy
60dbc5557c fix: remove _trace from helloOp
As per discordapp/discord-api-docs#967, _trace in OP10 HELLO is no
longer an array of strings, but rather an undefined glob of data that
presently contains a mixed bag of strings and objects.

type helloOp does not seem to be exposed outside of the library, so this
is not a breaking change; furthermore, the Trace field of helloOp was
not used anywhere within the library. It seems like it would be safer to
just remove the field outright, rather than accept it as an interface{}
and waste cycles unmarshaling data that is never used.

This is a critically breaking bug, as if the upstream change is merged,
bots using DiscordGo prior to this patch will be unable to connect; an
error would occur when trying to unmarshal the new data glob into a
[]string, causing (*Session).Open() to prematurely return.
2019-05-29 13:54:56 -04:00
robbix1206
aca3f3898c Remove code duplication in ChannelVoiceJoin (#611) 2018-11-05 17:37:18 -08:00
Connor Wright
c8554477e4 Add HeartbeatLatency method (#593)
* Latency method

* fixed typo

* fixed linter error

* Renamed Latency to HeartbeatLatency

* HeartbeatLatency now returns time.Time

* return time.Duration instead, since .Sub() returns that

* Add full-stops to end of comments
2018-09-26 13:22:21 -07:00
Bruce Marriner
8dc444f78a Moved noisy heartbeat logs to Debug 2018-08-31 14:26:02 +00:00
Skippy
c53a1b54c9
Merge pull request #578 from foxbot/feature/manual-voice-connection
feature: add ChannelVoiceJoinManual
2018-08-27 11:19:19 -05:00
Skippy
70fa40c872
Merge pull request #491 from cookkkie/patch-1
Drop the default gorilla websocket close handler
2018-08-27 10:33:16 -05:00
Christopher F
a089b52f64 feature: add ChannelVoiceJoinManual
This resolves #577.

ChannelVoiceJoinManual is a wrapper over sending an OP4 to Discord, for
initiating a voice server connection. The library's builtin voice
connection management locks/maps are skipped, and the library will not
attempt to manage this voice connection.

Users are expected to hook the VoiceServerUpdate event and forward the
data to an outside voice manager, such as Lavalink.
2018-08-22 21:04:44 -04:00
Chris Rhodes
7f8369a45f Clean up status methods. 2018-02-08 21:00:24 -08:00
Daniel Thorpe
e8cd93cf15 Add a listening status method (#508)
* Bump to v0.17.0

* Add members from GuildMembersChunk to state (#454)

* Revert "Add members from GuildMembersChunk to state (#454)" (#455)

This reverts commit e4487b30d4.

* travis: update go versions

* Allowed setting the game to null.

* Allowed for setting status to listening.

* Changed variable names for better consistency

* Reverted updateStatus to maintain API compatibility, instead added now
UpdateListeningStatus method which directly calls UpdateStatusComplex.

* Fix version to 0.18.0-alpha

* Make the new UpdateListeningStatus read a bit better.

* Updated setting game to nil for better compatibility.

* Remove the explicit nil check, as no longer seems to be needed.

* Fix comment styling.

* Remove idle as unused.
2018-02-08 20:50:07 -08:00
Carson Hoffman
a0faf9a0d0 Removed unnecessary error check (#505) 2018-01-22 14:32:00 -08:00
Anis B
4523c46927
Drop the default websocket close handler 2017-12-09 16:23:21 +01:00
vim2meta
1033558fcf
Update wsapi.go 2017-11-19 10:15:13 -05:00
Bruce Marriner
9e1220d82b Lint :) 2017-11-11 15:18:37 +00:00
Bruce Marriner
7d1657e59b Open() func now validates connection, fixed #198
Now the open function will follow through a bit more and insure that the
proper sequence of events happens during the Open call.  This required
some refactoring and a few mild changes in the onEvent func.
2017-11-11 15:04:56 +00:00
Bruce Marriner
a948670657 Add comments 2017-11-08 19:59:54 +00:00
Cory Ory
8737777ce7 Implement Raw sending of status (Rich Presence and Online Status) (#462)
* Added ability to change the online status

* Add structs for rick presence implementation

* Refractor and publicise UpdateStatusData

* Add UpdateStatusComplex for raw status data sending

* Case gameType to int, stopped it compiling

* Might want to gofmt.

Doesn't do it on save because Gogland removed it and their new thing I
can't make sense of.

* Revert "Added ability to change the online status"

This reverts commit 235cd15a8eebbec070cb95a5853295387bceae1c.

* Change gametypeto match

* Move RLock to UpdateStatusComplex
2017-10-22 14:08:08 -07:00
jD91mZM2
9da2c9e76a Added GameType (#435)
* Added GameType

* Delete useless function
2017-10-07 10:54:04 -07:00
Bruce
06b35cfe24 Linting. 2017-09-03 20:01:46 +00:00
Jonas is my name
308d058bf1 Fix presence update after breaking API change (#427) 2017-08-17 06:55:02 -07:00
Necroforger
013faa1da4 Hardcoded reactions ratelimit (#398)
* add custom ratelimits

* check for nil ratelimiter

* Don't expose custom ratelimits to Session

* attempt to fix race conditions

* use defer instead

* Slightly improved ratelimiter

You shouldn't need to change the ratelimiters ratelimits while its
running so I removed the functions SetCustomRatelimit and
RemoveCustomRatelimit.
2017-07-29 07:53:02 -07:00
legolord208
7bb0965a6f Updated to v6 (fixes #408) (#410)
* Updated to v6

* Unified websocket and REST version
2017-07-22 06:17:39 -07:00
Erik McClure
71ede90b56 Fix #406: reconnect() can be called while still connected (#407) 2017-07-18 18:21:45 -07:00
Erik McClure
bb4b96e26d Add heartbeat ACK response and error handling (#396)
* Add heartbeat ACK response and error handling

- Error when sending a heartbeat now triggers a reconnection
- Op7 now triggers a reconnection
- Session now tracks the last heartbeat ACK that was recieved. If the
last ACK is more than FailedHeartbeatAcks*heartbeatinterval in the past,
this is treated as a dead connection and a reconnection is forced.

* Address @iopred comments
2017-06-27 20:52:59 -07:00
legolord208
aa3973f956 Made error constants (Fixed #315) (#377) 2017-05-08 06:48:19 -07:00
Lukas
edd6e169fa Track voice-channel movements (#317) 2017-02-11 22:18:19 -08:00
jonas747
b07d1c4621 Fix leaking tickers (#314) 2017-01-23 12:13:59 -08:00
jonas747
bdb31f245d Fix all found race conditions, and dont send on nil channel (#307) 2017-01-10 20:01:47 -08:00
jonas747
2d50fc197f Fix racey heartbeat sequence (#303)
* Fix racey heartbeat sequence

* Change all sequence fields to int64
2016-12-28 11:59:02 -08:00
Kristian Klausen
b377944b97 Switch to V5 gateway (#300)
This switch the gateway to V5, and change the heartbeat logic to
get the heartbeat_interval from the new Hello opcode instant of
READY/RESUME event.
See: https://github.com/hammerandchisel/discord-api-docs/issues/18

Fix: #220
2016-12-25 16:22:14 -08:00
Bruce Marriner
9e777a083b Linting. 2016-12-11 12:45:34 -06:00
Chris Rhodes
36601253a4 Remove use of reflect.
This introduces gogenerate'ed EventHandlers from the files in events.go

This also adds support for AddHandlerOnce.
2016-12-03 23:31:07 -08:00
Chris Rhodes
c352d7016c Clean up ordering of internal handlers. (#285) 2016-11-12 11:50:06 -08:00
Chris Rhodes
3e7c0435bc Reduce severity of wsConn close error logging. 2016-11-05 00:16:15 -07:00
Chris Rhodes
c6ee0d2dd5 Clean up state access. (#261)
Clean up state access.
2016-09-27 22:45:12 -07:00
Chris Rhodes
b71136ac14 Merge pull request #259 from b1naryth1ef/bugfix/voice-state-update-api-usage
Remove API call in onVoiceStateUpdate
2016-09-27 22:35:56 -07:00
Chris Rhodes
2e2e02fc11 Support a very light state in all cases to support b1nzy's upcoming PR (#260)
Support a very light state in all cases to support b1nzy's upcoming PR
2016-09-27 22:09:44 -07:00
jonas747
1dcdf130fd Fix Another typo 2016-09-28 07:00:11 +02:00
jonas747
1ecb7458e9 Fix typos 2016-09-28 06:31:39 +02:00
andrei
1edd3b6484 Remove API call in onVoiceStateUpdate 2016-09-27 17:39:14 -07:00
jonas747
9c7c9d3fd2 Added RequestGuildMembers to request guild members from the gateway 2016-09-25 21:29:59 +02:00
Bruce Marriner
bbce2612b0 simi-properly close websockets and simplify voice reconnect 2016-07-06 20:31:47 -05:00
Bruce Marriner
ad91025f59 Don't delete VoiceConnections
But, don't add a VoiceConnection either if we don't successfully
connect.
2016-07-05 20:51:52 -05:00
Bruce Marriner
fb663ac348 Linting 2016-06-17 15:44:01 -05:00
Bruce Marriner
11f11de41c Protect writes to DataReady with mutex lock 2016-06-17 14:23:19 -05:00
Bruce Marriner
face6df4b6 Do not call session onEvent as goroutine
This is a stability improvement but may have a slight performance
impact. This change will be reviewed again later.  Doing this solves a
data race issue with the Sequence number that must be tracked for
gateway resume and heartbeats.  Event specific handlers are now called
as a goroutine though.
2016-06-17 12:24:32 -05:00
Bruce Marriner
e451cb36c3 Clear SessionID when reconnecting voice
Also added some more logging..
2016-06-17 10:24:15 -05:00
Bruce Marriner
9dc51d1c49 Only Shard when ShardCount > 1
Also cleaned up identify sending so there's now a function that handles
it instead of duplicate code.  Renamed handshake* structs to identify*
structs to make naming match up.
2016-06-14 13:45:38 -05:00
Bruce Marriner
d03b3eedfa Merge branch 'feature/sharding' of https://github.com/b1naryth1ef/discordgo into b1naryth1ef-feature/sharding 2016-06-14 11:45:59 -05:00