1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-01 12:34:28 +00:00
Commit graph

199 commits

Author SHA1 Message Date
Scott 10c8837000 api: Finalized buttons implementation (#200)
* all: Added Components fields to message-related types
* discord: Documented Reactions field
* discord: Implement fix for Component
* gateway: Added User and Message fields to InteractionCreateEvent
* api: Made InteractionResponseData fields optional for UpdateMessage responses
* api: Deprecated and updated interaction response types
* gateway: Update optional interaction event fields
* discord: Added ComponentWrap for json unmarshalling
* state: Update components on MessageUpdate
* Updated buttons example
2021-05-29 21:32:33 -07:00
Chan Wen Xu c880cb2fc8 interaction: Implement buttons 2021-05-29 14:16:44 -07:00
Starshine System 20166f33cc
gateway: fix Joined field in GuildCreateEvent (#193) 2021-04-11 16:56:05 -07:00
diamondburned 728bc5c472 Gateway: Test Reconnect error 2021-04-07 11:42:13 -07:00
Maximilian von Lindern ebc74e3168
Gateway: Sharding callback, proper closing (#190)
* Gateway: Fix gateway reconnect

This commit uses the correct timeout, Gateway.ReconnectTimeout, when reconnecting. Furthermore, it adds a delay between consecutive, failed reconnects.

* Gateway: Stop pacemaker when calling Gateway.CloseGracefully

* API: remove unnecessary leading/trailing whitespaces

* Gateway: Add Gateway.OnScalingRequired callback

* Gateway: Make all user initiated user closures graceful and ensure that closures are respected during reconnects

* Gateway: Fix typo

* Gateway: Add Gateway.ReconnectAttempts and deprecate .ReconnectTimeout

* Gateway: Add Gateway.Pause and reexport .Reconnect and .ReconnectCtx

* Gateway: Improve the Gateway.OnShardingRequired docs

* Wsutil: Code cleanup
2021-04-07 11:38:26 -07:00
diamondburned 9925461a25 Gateway: Potential fix for URL() 2021-04-05 12:20:56 -07:00
diamondburned c9a7ec8122 Gateway: Add URL test 2021-04-05 12:20:56 -07:00
diamondburned 2dadb0701d Gateway: Add automatic BotData connection
This commit modifies Gateway constructors to allow the user to easily
feed existing Identifier instances as well as updating those instances
to adhere to the Discord-returned gateway rate limits.

These changes should make it easier for typical bot sharding, although
automatic sharding is not implemented.
2021-04-05 12:20:56 -07:00
diamondburned 968112fb53 Discord: typed snowflake for Interaction 2021-02-17 17:41:19 -08:00
diamondburned 5a18435190 Gateway: Better Activities type for UpdateStatusData
This is a breaking change.
2021-02-07 17:03:12 -08:00
Maximilian von Lindern a969b11709
Gateway: Add graceful closing with CloseGracefully (#185)
* gateway: add the possibility of graceful closure

* wsutil: rename ConnGracefulCloser to GracefulCloser

* Gateway: rename Gateway.CloseSession to .CloseGracefully
2021-01-29 20:25:10 -08:00
Matthew Penner 7c3374543e Discord: Add basic support for slash commands 2021-01-27 10:44:14 -08:00
diamondburned 169b361262 Gateway: Add Threads into GuildSubscribe 2021-01-01 00:33:35 -08:00
diamondburned c6d8c741e8 CI: Add perseverance test for Gateway 2020-12-31 23:48:29 -08:00
diamondburned 7b67a98405 Gateway: Prevent heartbeat reconnecting twice 2020-12-31 23:01:38 -08:00
diamondburned f1f052180b Heart: Improve thread-safety and pace responsiveness
This commit consists of these smaller commits:

    Gateway: SessionID to be a method for thread safety

	This commit breaks the SessionID field of the Gateway struct to
	be thread-safe by wrapping its access with a read-write mutex.
	As this is a bug fix, it is reasonable of a breaking change

    Heart: Allow later binding of event channel

    Voice: Use the new Heart API

    Heart: Fixed data races

    Heart: Allow changing pace, thread-safe Heartbeat
2020-12-31 01:32:45 -08:00
diamondburned 05de2d7b61 Gateway: Made Shard field empty for default 2020-12-30 23:43:08 -08:00
diamondburned 088b304303 Gateway: Rename MessageNotifications to Notifications for consistency 2020-12-19 19:22:35 -08:00
diamondburned d5f3979f95 Gateway: Rename UserGuildMute to UserMuteConfig for correctness 2020-12-19 19:06:09 -08:00
diamondburned 7aff3f9f24 Gateway: Added MuteConfig into UserChannelOverride 2020-12-19 18:59:15 -08:00
diamondburned 4e62f120a2 Gateway: Readd Presences into Ready 2020-12-19 18:46:21 -08:00
diamondburned f11edb7260 State: Add Ready Supplement handlers 2020-12-18 22:51:26 -08:00
mavolin 9911a3d662 State: fix caching not working properly on user accounts 2020-12-08 11:50:35 -08:00
diamondburned 5e2af90fd0 Gateway: Rollback weird user changes 2020-12-01 18:07:42 -08:00
diamondburned b8994ed0da Voice: Remove state-keeping of sessions
This commit gets rid of all the code that previously managed different
voice sessions in different guilds. This is because there is rarely ever
a need for this, and most bots that need this could do their own
keeping.

This change, although removes some features off of the package, adds a
lot of clarity on what to do exactly when it comes to connecting to a
voice channel.

In order to make the migration process a bit easier, an example has been
added which guides through using the voice.Session API.
2020-11-30 19:12:20 -08:00
diamondburned c6679dc52c State: Separate Store into smaller interfaces, Cabinet API
This commit refactors the Store interface in State into smaller
interfaces in package store. These interfaces are combined into one
structure called a "Cabinet". The default implementation of those
interfaces have been rewritten in package defaultstore, while the old
no-op implementation stays with the store package.

This commit also omitted several state handlers for user events, as it
is unclear what they are actually structured like.
2020-11-29 16:57:58 -08:00
diamondburned a2333996a2 Gateway: Presence to contain user and guild fields
This commit changes the gateway.Presence struct to be similar to commits
prior to the last refactor, that is, the struct would have the User and
GuildID fields. This is done so it's easier to store them.
2020-11-28 22:36:33 -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 aff386402f Gateway: remove GuildSubscriptions from IdentifyData
With the requirement of intents on Gateway v8, the guild_subscriptions field has no effect, and is therefore removed
2020-11-03 10:18:04 -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 f3372e016a Gateway: Added missing intents in tests 2020-10-30 12:00:41 -07:00
diamondburned 2a2244c965 Gateway: Use API v8 version instead of its own v6 2020-10-30 11:24:10 -07:00
diamondburned 0ead315aa3 Gateway: Fixed race in test Fatal 2020-10-30 11:15:58 -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 b8e4b2cf56 Gateway: Added an Event to Intents map for convenience 2020-10-28 19:44:04 -07:00
diamondburned c00d31ce30 Gateway: Added missing MessageReactionRemoveEmojiEvent constructor 2020-10-28 19:39:18 -07:00
diamondburned fd16db1385 Gateway: Fixed MessageReactionRemoveEmoji not having Event suffix 2020-10-28 19:31:43 -07:00
diamondburned 75df94d9f4 *: Migrated Go Modules to v2 2020-10-28 15:39:59 -07:00
diamondburned 8aa60ebf8e *: Removed the Game field
The Activities field should now be used. Access the first element.
2020-10-28 14:01:08 -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 91ee92e9d5 Gateway: Fixed a race condition on ReconnectOP 2020-10-21 22:42:16 -07:00
diamondburned 1bec57523d Gateway: GuildSubscribeData should omit empty Channels map 2020-10-17 03:18:50 -07:00
diamondburned 86dd05da9e Gateway: Fixed empty Query on RequestGuildMembersData broken 2020-10-16 02:17:59 -07:00
diamondburned fd818e181e Gateway: GuildFolderID is now a signed int because Discord 2020-08-19 21:54:20 -07:00
diamondburned de61fd912d wsutil: Made PacemakerLoop valid as zero-value 2020-08-19 21:30:57 -07:00
diamondburned af7f413cea Gateway: Clarified GuildMemberListGroup.ID docs 2020-08-14 21:13:48 -07:00
diamondburned c819b56170 Gateway: Added a custom GuildFolderID type 2020-08-14 18:13:35 -07:00
diamondburned eb46a89e6c Gateway: Fixed GuildFolder.ID unmarshaling 2020-08-14 17:57:06 -07:00
diamondburned 77b1b08bce Heart: Better synchronization on close methods 2020-07-30 12:44:50 -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
Tadeo Kondrak b8f6fbbda9 Gateway: Fix type of GuildFolder.ID 2020-07-29 16:58:33 -07:00
Tadeo Kondrak d290b0d01c *: Add typed Snowflake IDs (#122)
This PR closes #120.
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 6717f8002c Gateway: Fixed autoreconnect misusing context 2020-07-15 16:39:40 -07:00
diamondburned a1038cb8bb Gateway: Fixed wrong usage of Context in Gateway reconnection 2020-07-15 16:32:53 -07:00
diamondburned 9d7f5cb953 Gateway: Deprecated useless type definitions for embedded structs 2020-07-14 21:38:31 -07:00
diamondburned 7572caad31 Discord: Added Relationship API methods; moved structs around 2020-07-14 18:01:24 -07:00
diamondburned 91e494ba51 Gateway: Changed Relationship struct for type and name claritifcation 2020-07-11 13:25:29 -07:00
diamondburned edb8a46ef2 Gateway: Added intent helpers and more context API support 2020-07-11 12:50:32 -07:00
diamondburned d3d9811276 Gateway: Added Relationship events and handlers; minor reformatting 2020-07-11 00:02:57 -07:00
diamondburned (Forefront) 64c6ca7916 Gateway: Fixed GuildCreateEvent not having Channels 2020-05-17 22:48:16 -07:00
mavolin 41ce1f389e
make all error messages lowercase 2020-05-16 23:14:49 +02:00
diamondburned (Forefront) adb23eeb8e Gateway: Added new InviteCreateEvent and InviteDeleteEvent 2020-05-12 17:51:23 -07:00
mavolin f453c1eefa
Gateway: Fix #45 2020-05-12 04:54:16 +02:00
diamondburned (Forefront) 23b0abdfec Adopted several packages to use NullSnowflake and NullSeconds 2020-05-08 14:25:07 -07:00
diamondburned (Forefront) 51e88a47b2 Gateway/Voice: Improved the event loop, fixed race conditions 2020-04-25 00:13:07 -07:00
diamondburned ccf4c69801
Merge pull request #14 from matthewpi/feature/voice 2020-04-24 19:58:26 -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) a2a1ccd01e Gateway: Fixed Invalid Session retrying forever bug 2020-04-22 14:45:19 -07:00
Matthew Penner f429010ded Add janky voice support 2020-04-21 16:37:22 -06:00
diamondburned (Forefront) 5c85e4aa64 Gateway: Fixed a typo in GuildCreateEvent 2020-04-21 15:32:00 -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) 9873d475aa State: Added Reaction state handlers 2020-04-12 16:14:27 -07:00
diamondburned (Forefront) 4e4ebde93a Gateway: Deprecated Wait(), fixed ReconnectOP bug 2020-04-12 11:06:43 -07:00
diamondburned (Forefront) 320e8a52f1 Gateway: Fixed unexpected ticker.Stop() blocking behavior 2020-04-11 20:38:10 -07:00
diamondburned (Forefront) 01e52334c6 Gateway: Possible bug fix, added more verbose debugging 2020-04-11 17:47:09 -07:00
diamondburned (Forefront) 06136b7d5f Websocket: Replaced Conn's mutices with channels 2020-04-10 20:03:52 -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) 6dafb30401 State: Added more wrappers for direct messaging channels 2020-04-07 19:33:56 -07:00
diamondburned (Forefront) e8694c74e5 Gateway: Slightly better documenting 2020-04-07 12:26:15 -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) b5f7af70f3 Gateway: Changed UpdateStatus to be more valid 2020-03-31 20:45:56 -07:00
diamondburned (Forefront) f71852604b Gateway: Fixed Since omitempty condition 2020-03-30 23:02:25 -07:00
diamondburned (Forefront) 727f23f8f4 Gateway: Added missing Activities slice in UpdateStatus 2020-03-30 22:22:32 -07:00
diamondburned (Forefront) c9829b9e28 Gateway: Fixed invalid Since type for UpdateStatusData 2020-03-30 21:46:03 -07:00
diamondburned (Forefront) 00481b5490 Gateway: Fixed UserNotification constants 2020-03-26 19:11:25 -07:00