Commit Graph

60 Commits

Author SHA1 Message Date
mavolin 9911a3d662 State: fix caching not working properly on user accounts 2020-12-08 11:50:35 -08:00
diamondburned 6ef093eb98 Gateway: Refactor, v8 user struct updates
This commit refactored several structures from package discord to be in
package gateway. Those structures are mostly presence ones, which per
official documentation has a lot more to do with the Gateway API than
the REST API or anything else.

This commit also renamed several global variables to have a more
consistent and obvious name.

As of v8, the user API has had a lot of minor and some major changes,
especially regarding its Ready event API. The most significant change is
the addition of the ReadySupplemental event as well as several changes
to the Ready field itself.

All of these changes above are breaking, and they have already broken
the state package. These breaking changes will be addressed in other
packages by the next commit.
2020-11-28 17:22:03 -08:00
Maximilian von Lindern 3230916c45
State: don't check store if resource is not tracked through intents (#163)
Partially reviewed; good for the most part.
2020-11-19 10:43:31 -08:00
mavolin 88258b51c2 replace usage of discordapp.com with discord.com in docs 2020-11-03 10:14:53 -08:00
diamondburned a46d3c2c8d wsutil: Added possibly missing Reset cases and more debug logs 2020-10-31 15:54:51 -07:00
Maximilian von Lindern 607250ae55
Gateway: Added reconnect timeout; fixed UA (#154)
* Gateway: use gateway version 8

* API: remove old v0.0.1 version tag

* Discord: fix typos

* Gateway: add timeout

* Gateway: revert to returning errors on ReconnectCtx
2020-10-30 13:41:04 -07:00
diamondburned 2a2244c965 Gateway: Use API v8 version instead of its own v6 2020-10-30 11:24:10 -07:00
diamondburned 16c1658163 {,Voice}Gateway: Refactored Closing
This commit refactors both wsutil, the normal Gateway and the Voice
Gateway to have better closing behavior, which should assume less and
cover edge cases completely.
2020-10-30 11:02:37 -07:00
diamondburned 9899f6073b Bot: Added automatic Intents detection from handlers
This commit adds automatic Intents detection into package bot. When the
Start function is used, the intents will be OR'd after running the
options callback.

This commit also breaks the old "AddIntent" methods to rename them to
"AddIntents" for correctness.
2020-10-28 22:49:18 -07:00
diamondburned 75df94d9f4 *: Migrated Go Modules to v2 2020-10-28 15:39:59 -07:00
diamondburned 6c332ac145 {Voice,}Gateway: Fixed various race conditions
This commit fixes race conditions in both package voice, package
voicegateway and package gateway.

Originally, several race conditions exist when both the user's and the
pacemaker's goroutines both want to do several things to the websocket
connection. For example, the user's goroutine could be writing, and the
pacemaker's goroutine could trigger a reconnection. This is racey.

This issue is partially fixed by removing the pacer loop from package
heart and combining the ticker into the event (pacemaker) loop itself.

Technically, a race condition could still be triggered with care, but
the API itself never guaranteed any of those. As events are handled
using an internal loop into a channel, a race condition will not be
triggered just by handling events and writing to the websocket.
2020-10-22 10:47:27 -07:00
diamondburned de61fd912d wsutil: Made PacemakerLoop valid as zero-value 2020-08-19 21:30:57 -07:00
Maximilian von Lindern 1585797b52 *: Linting and typo fixes (#134)
* Linting and typo fixes

* Linting and typo fixes

* revert comma fix
2020-07-29 16:58:33 -07:00
diamondburned 24f7ed0499 Gateway: ReconnectCtx now returns error; fixed test 2020-07-18 18:33:07 -07:00
diamondburned a1038cb8bb Gateway: Fixed wrong usage of Context in Gateway reconnection 2020-07-15 16:32:53 -07:00
diamondburned edb8a46ef2 Gateway: Added intent helpers and more context API support 2020-07-11 12:50:32 -07:00
mavolin 41ce1f389e
make all error messages lowercase 2020-05-16 23:14:49 +02:00
diamondburned (Forefront) 51e88a47b2 Gateway/Voice: Improved the event loop, fixed race conditions 2020-04-25 00:13:07 -07:00
diamondburned (Forefront) 95624292f7 Gateway: Deprecated OP chan API, use PacerLoop.Extras instead 2020-04-24 15:32:14 -07:00
diamondburned (Forefront) 54ac0a6951 Gateway: Migrated to wsutil.PacemakerLoop 2020-04-24 15:30:15 -07:00
diamondburned (Forefront) 443ec791af Heart: Moved PacemakerLoop to wsutil, changed Gateway abstractions to generic ones 2020-04-24 15:09:05 -07:00
diamondburned (Forefront) 2f076c041e Gateway: Migrated functions and variables to other packages, added JSON default codecs 2020-04-23 23:34:08 -07:00
diamondburned (Forefront) 748ad5641c API: Added AllowedMentions and more tests 2020-04-19 16:35:37 -07:00
diamondburned (Forefront) 2afe683b7d Utils: Added HTTP drivers 2020-04-19 14:53:53 -07:00
diamondburned (Forefront) bf93a9cee9 Changed endpoint constants to variables 2020-04-19 09:30:12 -07:00
diamondburned (Forefront) b9384042bb Gateway: Added GatewayBot 2020-04-19 09:17:04 -07:00
diamondburned (Forefront) 813be25713 Gateway: Fixed infinite InvalidSession loop 2020-04-13 18:23:38 -07:00
diamondburned (Forefront) 4e4ebde93a Gateway: Deprecated Wait(), fixed ReconnectOP bug 2020-04-12 11:06:43 -07:00
diamondburned (Forefront) 01e52334c6 Gateway: Possible bug fix, added more verbose debugging 2020-04-11 17:47:09 -07:00
diamondburned (Forefront) cc530ce7a2 Bot: Allow func(T), added more documentation, minor fixes 2020-04-09 13:49:12 -07:00
diamondburned (Forefront) be12849668 Changed internal/ to utils/, allowing external imports 2020-04-08 19:28:40 -07:00
diamondburned (Forefront) 2f597ebc0b Session: Added an AfterClose handler as a *session.Close event 2020-04-06 19:36:06 -07:00
diamondburned (Forefront) 33061e916f Gateway: Now waits for either READY or RESUMED before finishing Open() 2020-04-06 13:27:33 -07:00
diamondburned (Forefront) 9f5c2ac958 Gateway: Switched to gorilla/websocket, fixes #11 2020-04-06 13:27:29 -07:00
diamondburned (Forefront) 743a8a8fd9 API: Fixed FormatEmojiAPI 2020-03-22 15:23:29 -07:00
diamondburned (Forefront) 8899462ff0 Gateway: Added undocumented GuildMemberListUpdate event 2020-03-15 22:55:45 -07:00
diamondburned (Forefront) 22ef50c499 Gateway: Fixed bug where WS errors block forever 2020-03-07 11:50:30 -08:00
diamondburned (Forefront) 403e4970f7 Gateway: Fixed a deadlocking mutex 2020-03-02 19:18:33 -08:00
diamondburned (Forefront) 0aebea60bd Gateway: Minor bug fixes 2020-03-01 16:39:40 -08:00
diamondburned (Forefront) f0102d765f Gateway: Added a retry limit
State: Event handlers now handle all of Ready's Guilds field
Session: Added Wait, which blocks until SIGINT or Gateway error
2020-02-29 18:13:58 -08:00
diamondburned (Forefront) 220eb5ff42 Gateway: Fixed OP chan not having a concrete type 2020-02-25 22:37:26 -08:00
diamondburned (Forefront) 587d36fd6c Gateway: Open now fails at once, only Reconnect retries forever. 2020-02-19 19:36:00 -08:00
diamondburned 76c7760c24 Gateway: Removed redundant context 2020-02-11 09:29:30 -08:00
diamondburned 3288f2d19c
Gateway: Fix race conditions and fatal reconnecting (#7) 2020-02-07 22:17:27 -08:00
diamondburned (Forefront) 85b793a1a7 Fixed some race conditions 2020-02-02 14:12:54 -08:00
diamondburned (Forefront) b62ba3ecc0 More race condition fixes 2020-01-28 19:54:22 -08:00
diamondburned (Forefront) 3770927a48 Bot: trivial fixes 2020-01-28 16:01:39 -08:00
diamondburned (Forefront) 3ca1d352c9 Fixed a ridiculous race condition in the gateway 2020-01-20 03:06:20 -08:00
diamondburned (Forefront) aa4154e73c Minor fixes that doesn't really fix anything 2020-01-20 01:32:28 -08:00
diamondburned (Forefront) ac685b0df4 Minor fixes, undocumented things, and editorconfig 2020-01-19 13:54:16 -08:00