1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-01 04:24:19 +00:00
Commit graph

204 commits

Author SHA1 Message Date
diamondburned ff26fded59
gateway: Run go generate for new event 2024-01-06 19:13:59 -08:00
diamondburned f7f228a848
gateway: Add undocumented ConversationSummaryUpdateEvent 2024-01-02 01:35:16 -08:00
diamondburned b0a773c3f8
*: Improve WSDebug logging in tests 2023-11-04 02:27:37 -07:00
Cléo Rebert d36955acea Move away from github.com/pkg/errors
Signed-off-by: Cléo Rebert <cleo.rebert@gmail.com>
2023-09-19 11:37:24 -07:00
diamondburned ba9d20b34b
gateway: Add IntentMessageContent
See https://discord.com/developers/docs/topics/gateway#message-content-intent.
2023-03-15 15:16:42 -07:00
diamondburned 23140acf87
gateway: Load latency on reconnection 2023-02-12 15:52:18 -08:00
ayn2op 55d19000a1
discord: Rename IntentGuildBans; add GuildAuditLogEntryCreateEvent (#370)
* Rename GuildBans intent & add GUILD_AUDIT_LOG_ENTRY_CREATE event

* Add IntentGuildBans constant for backward compatibility
2023-01-27 01:34:50 -08:00
diamondburned 5a156cc699
gateway: Expose GatewayOpts getter 2022-11-18 02:01:18 -08:00
diamondburned 87c479a2dc
gateway: Use PartialUnmarshal for ReadyEventExtras 2022-11-03 02:30:25 -07:00
diamondburned 60ed12f3c0
gateway: Add Ready.SessionID 2022-10-31 04:34:21 -07:00
diamondburned f8d6199e80
gateway: Re-type SessionsReplaceEvent 2022-10-31 04:30:10 -07:00
diamondburned 60bcb4c966
gateway: Add Ready.Sessions 2022-10-31 04:11:45 -07:00
diamondburned 83cf774073
gateway: Separate Ready to ReadyEventExtras
This commit separates the undocumented fields of Ready to
ReadyEventExtras. Realistically, this is never an issue for bots, but it
might cripple non-bot users when Discord makes breaking changes to the
API.

This change allows Ready to still be unmarshaled even when the
undocumented fields cannot be unmarshaled. It also adds a new json.Raw
field that allows the whole Ready event to be unmarshaled differently.

This new ReadyEventExtras is also no longer marshaled as part of Ready.
Instead, none of its field will be present. Although this is a breaking
change, it solely concerns non-bot APIs, so it's acceptable.
2022-10-03 23:18:43 -07:00
diamondburned d952c98829
gateway: Fix RequestGuildMembersCommand.GuildIDs 2022-10-03 04:48:50 -07:00
diamondburned d97492348d
gateway: Fix RequestGuildMembersCommand for empty query 2022-10-03 04:47:04 -07:00
diamondburned afeacebced
gateway: Removed unused test functions 2022-10-03 04:47:04 -07:00
diamondburned 10589eab14
gateway: Do not resume after 15m
Fixes #341.

Unsure if this is a good idea, but 15 minutes seems enough.
2022-09-13 19:50:42 -07:00
p5nbTgip0r dcfc9b19d1 gateway: Add IsPending for GuildMemberUpdateEvent 2022-08-22 14:43:29 -07:00
diamondburned af940e5a37
gateway: Workaround for lack of heartbeat revival
Fixes a regression from v2's gateway.
2022-08-15 14:09:53 -07:00
diamondburned c71f48c163
Revert "ws: Add LastAcknowledgedBeat"
This reverts commit 660d9893e1.

The commit introduces regular incorrect reconnections. It will be
tracked in another branch and re-merged later once fixed.
2022-04-12 10:55:42 -07:00
diamondburned 660d9893e1
ws: Add LastAcknowledgedBeat
This commit adds ws.Handler.LastAcknowledgedBeat to allow ws.Gateway to
monitor whether or not the server is still reachable.

It fixes #324.
2022-04-12 10:38:41 -07:00
diamondburned 4108d10b44
gateway: Fix RequestGuildMembersCommand 2022-04-08 05:47:21 -07:00
diamondburned 816a53b1e1
gateway: Test ReadyEvent.Version 2022-04-02 22:52:57 -07:00
diamondburned 6b835a58c7
*: Increase test timeout duration
See if CI passes this time.
2022-04-02 22:44:08 -07:00
ItsLychee 92897b4fc3
discord: Support guild Scheduled Events (#319)
* implement the gateway side of guild scheduled event
* Add proper punctuation to each docstring
* Fix UserAdd and UserRemove events
* Add MANAGE_EVENTS permission
* Implement the API-side of scheduled events
* Add ScheduledEvent method
* Cleanup
2022-04-02 22:36:45 -07:00
diamondburned 08a1db0e4a
state: Fix up ReadyEvent 2022-04-01 04:42:55 -07:00
Neo 87be6b09c1 gateway: Added the struct field of the Thread Members Update event. 2022-03-09 11:02:30 -08:00
Sam 23f5771325
gateway: Remove 4003 from fatal close codes (#316)
https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes
2022-02-25 05:10:31 -08:00
starshines 7727d140a0
gateway: Update CommunicationDisabledUntil in GuildMemberUpdateEvent.UpdateMember (#307) 2022-02-05 15:05:13 -08:00
diamondburned 82c2b9e840
gateway: Add Event = ws.Event 2021-12-25 15:17:20 -08:00
starshines bc8a2b0cae
discord: Add timeouts (#299) 2021-12-20 15:56:11 -08:00
diamondburned 54cadd2f45 gateway: Refactor for a better concurrent API
This commit refactors the whole package gateway as well as utils/ws
(formerly utils/wsutil) and voice/voicegateway. The new refactor
utilizes a design pattern involving a concurrent loop and an arriving
event channel.

An additional change was made to the way gateway events are typed.
Before, pretty much any type will satisfy a gateway event type, since
the actual type was just interface{}. The new refactor defines a
concrete interface that events can implement:

    type Event interface {
        Op() OpCode
        EventType() EventType
    }

Using this interface, the user can easily add custom gateway events
independently of the library without relying on string maps. This adds a
lot of type safety into the library and makes type-switching on Event
types much more reasonable.

Gateway error callbacks are also almost entirely removed in favor of
custom gateway events. A catch-all can easily be added like this:

    s.AddHandler(func(err error) {
        log.Println("gateway error:, err")
    })
2021-12-14 13:49:34 -08:00
diamondburned 331ec59dec discord: Refactor interactions and components
This commit gets rid of contain-it-all structs and instead opt for
interface union types containing underlying concrete types with no
overloading.

The code is much more verbose by doing this, but the API is much nicer
to use. The only disadvantage in that regard is the interface assertion
being too verbose and risky for users at times.
2021-11-12 11:38:36 -08:00
diamondburned 0d13edc8fd
gateway: Add ClientState and Capabilities for Identify
This commit preps the gateway for user account usage.
2021-11-03 15:29:29 -07:00
diamondburned efde3f4ea6
state, handler: Refactor state storage and sync handlers
This commit refactors a lot of packages.

It refactors the handler package, removing the Synchronous field and
replacing it the AddSyncHandler API, which allows each handler to
control whether or not it should be ran synchronously independent of
other handlers. This is useful for libraries that need to guarantee the
incoming order of events.

It also refactors the store interfaces to accept more interfaces. This
is to make the API more consistent as well as reducing potential useless
copies. The public-facing state API should still be the same, so this
change will mostly concern users with their own store implementations.

Several miscellaneous functions (such as a few in package gateway) were
modified to be more suitable to other packages, but those functions
should rarely ever be used, anyway.

Several tests are also fixed within this commit, namely fixing state's
intents bug.
2021-11-03 15:16:02 -07:00
diamondburned 7f4daccd2d
shard: Separate state's cabinet, fix return bugs
This commit makes it so that all sharded state.State instances will have
its own cabinet store on construction. This ensures that when a State is
reconnected, a Ready event won't wipe the cabinet for all other states.

This commit also fixes a bug with the Shard() and FromGuildID() getters.
2021-10-31 13:10:34 -07:00
Maximilian von Lindern 528281b739
gateway: Fix Context overwrite in Gateway.Open (#285)
* Gateway: Fix Gateway.Open overwriting the context argument

* WSUtil: Remove max context timeout in Websocket.Dial

* WSUtil: Use Websocket.Timeout if a no-deadline context is given to .Dial

* WSUtil: Add doc to Websocket.Timeout clarifying that it must not be changed after use
2021-10-20 15:06:06 -07:00
starshines ca70e0cca9
discord: Add per-guild avatars, ModifyMe -> ModifyCurrentUser (#278)
* v3: discord, api, gateway: add per-guild avatars

* api: rename ModifyMe to ModifyCurrentUser
2021-09-28 11:46:36 -07:00
samhza e203e31ab3
discord: Update to match current API docs (#277)
* discord: update permission constants

* discord: update MessageType constants, add ephemeral field to Attachment

Renamed ApplicationCommandMessage to ChatInputCommandMessage and add
ContextMenuCommand. Add the ephemeral field to Attachment.

* discord: add version field to Command

* gateway: remove ApplicationCommandUpdateEvent

52f1824451
2021-09-23 21:37:50 -07:00
Maximilian von Lindern 5d2d39d422
gateway: Fix typo in GuildEmojisUpdateEvent.Emojis JSON tag (#276) 2021-09-22 10:57:14 -07:00
samhza 4023a58f67
gateway: Change type of IdentifyData.Intents to option.Uint (#275) 2021-09-09 18:45:08 -07:00
samhza dc92845315
discord: move Interaction over; update api.CommandCreateData (#274)
- Moved gateway.InteractionCreateData to discord.Interaction, now
gateway.InteractionCreateData is a struct that wraps
discord.Interaction.
- Split InteractionData into CommandInteractionData and
ComponentInteractionData.
- Renamed ButtonInteraction to ComponentInteraction.
- Updated api.CommandCreateData to add new fields.
- Update Component types' Type() methods to pointer receivers.
2021-09-09 16:06:44 -07:00
starshines f7880b91ee
discord: Add select component type (#260) 2021-08-10 14:02:30 -07:00
Maximilian von Lindern c00567599b
api: Threads (#257)
* api/gateway: Implement threads

* discord/api: rename PermissionOverwrites fields to Overwrites

* discord: rename Minutes to ArchiveDuration

* discord: Rename ArchiveDuration constants

Co-authored-by: diamondburned <datutbrus@gmail.com>
2021-08-08 13:19:15 -07:00
Hamza Ali 0d7774bd6a
gateway: Skip unknown events while reconnecting (#255)
This change skips events that are unknown while the bot reconnects. This
is an event that is particularly rare as it requires unimplemented
events being called in the time before a bot's HELLO -> RESUME events
are called. This change explicitly returns unknown events as a special
time defined in wsutil/op.go and ignores them from reaching gateway/op.go
2021-08-03 18:00:31 -07:00
Starshine System 42aa73a592 gateway: change InteractionOption.Value to json.Raw, add helper methods 2021-08-03 09:07:09 -07:00
diamondburned 6c349d9750 shard: Unwrap Shard in ForEach 2021-06-24 21:20:58 -07:00
Germano Eichenberg 94090b92ff
discord, gateway: Add IsPending to Member & SupplementalMember (#231) 2021-06-17 13:40:57 -07:00
diamondburned da7c6c6dba gateway: Allow custom SessionID 2021-06-14 15:23:08 -07:00
diamondburned 5b328bdab0 shard: Remake shard manager (#226) 2021-06-14 15:22:55 -07:00