Commit Graph

1067 Commits

Author SHA1 Message Date
izexi
0dd3ed72ef fix(Partials): Client#event:messageUpdate(oldMessage) and MessageReactionAdd on guild channels (#3250)
* ref: add getPayload and use for other get* methods

* return existing data.*

* use Action.getUser()
2019-05-07 20:56:39 +01:00
Gus Caplan
3d4513268d Add optional zstd for faster WebSocket data inflation (#3223)
* zstd
2019-05-07 14:30:34 +01:00
Darqam
8915bc1d37 docs:(Client): disambiguate the description of channels collection (#3251)
* Disambiguate the description of <client>.channels

Although not explicitly said, the current wording makes it seem like all channels are cached and available at any time in this store. Hopefully this variation makes it a bit clearer.

* make more explicit (I think)

* remove trailing white spaces
2019-05-06 20:08:56 +02:00
izexi
176fc47699 feat(Actions): use partials for messageDeleteBulk (#3240)
* make use of partials

* don't cache the messages

* pass each message within the for..of iteration
2019-05-03 17:38:57 +02:00
Jacz
692494dc04 feat(VoiceState): self mute/deaf methods (#3243)
* Implemented setSelfMute/Deaf, done typings, fixed bug in VoiceState with errors.

* Completed requested changes

* return send in sendVoiceStateUpdate so its a promise, update typings

* Updated methods to return a boolean

* Requested changes

* Fix bug

* Update src/structures/VoiceState.js

Co-Authored-By: MrJacz <23615291+MrJacz@users.noreply.github.com>

* fix
2019-05-03 17:11:11 +02:00
Vlad Frangu
a59968f7de src: add news and store channels, and missing guild props (#3168)
* src: Implement store and news channels!

* src: Remove code dupe

* src: Add missing guild properties

* docs: Add a small notice that the channel type may also change

* src: Remove re-creation of the MessageStore

* lint: Unused Import

* src: Requested changes for StoreChannels

* typings: Fix typings

* src: Moar guild updates

* src: Set maximumPresence to the data prop, the already existent one, or default to 5000

* typings: afkChannel is a VC

I keep confusing them, ffs

Co-Authored-By: vladfrangu <kingdgrizzle@gmail.com>

* docs: Document that maximumMembers and maximumPresences may be inaccurate before fetching

* src Appels requested changes
2019-05-03 17:08:07 +02:00
Amish Shah
bcb0cd838b voice: remove Guild.voiceConnection and VoiceChannel.connection 2019-04-29 19:29:16 +01:00
Amish Shah
dd44647537 voice: Guild.voiceConnection => Guild.voice.connection 2019-04-29 19:24:27 +01:00
Amish Shah
ce1e3d2084 feat(VoiceConnection): add .voice 2019-04-29 19:13:41 +01:00
Vlad Frangu
d7a9b74523 src: Replace instanceof Array checks with Array.isArray and instanceof Buffer with Buffer.isBuffer (#3227)
* src: Replace instanceof Array checks with Array.isArray

* src: Buffer.isBuffer instead of instanceof Buffer
2019-04-29 17:49:41 +01:00
bdistin
9b0f4b298d feature: public raw events (#3159)
* add a public alternative to the private raw event

while retaining raw for use in debugging privately

* only emit dispatch packets

* requested changes

TIL, that's neat

* fix padding

* requested changes

* Update WebSocketManager.js
2019-04-29 17:37:57 +01:00
izexi
23191da13d feat(Partials.GuildMember): GuildMemberRemove & Guild#me (#3229)
* use partials for GuildMemberRemove & Guild#me

* oops

* guild.members instead of Action.members

Co-Authored-By: izexi <43889168+izexi@users.noreply.github.com>
2019-04-29 17:05:52 +01:00
Vlad Frangu
bc31746621 src: Client#readyAt should be updated when triggerReady is called (#3234) 2019-04-29 17:03:29 +01:00
Vlad Frangu
577636a46d src: fix random broken reconnects (#3233) 2019-04-27 08:25:24 +01:00
Vlad Frangu
de79bba965 src: Fix type error in WebSocketShard#onError (#3231) 2019-04-24 16:53:41 +02:00
SpaceEEC
39115c8acc fix(MessageCreateAction): remove redundant GuildMemberStore#add call
This was also causing a bug where GuildMember#_roles was patched with a GuildMemberRoleStore
2019-04-23 21:21:41 +02:00
Vlad Frangu
1514df0f87 fix: emit resume event, silent disconnects, error event param (#3192)
* src: Fix shardResumed event not being emitted

* docs: Document Client#error again

* src: Fix onError due to incorrect typings

* src: handle onError properly for both uws and ws

* src: Try to fix silent disconnects when using uWs

* fix(WebSocketShard): uws emits plain objects, not errors

Emitting line of code: 39aa429f94/src/uws.js (L80-L83)
Listener attaching is here: https://github.com/discordjs/uws/blob/master/src/uws.js#L128
For reference, found a clue here: https://github.com/discordjs/discord.js/issues/1528
2019-04-21 09:32:16 +02:00
SpaceEEC
cde955c766 fix(PresenceUpdateAction): emit presences again (#3214)
* fix(PresenceUpdateAction): emit presences again

* update typings
2019-04-19 08:49:17 +02:00
Deivu (Saya)
b5320299f7 Only reset sessionID when close code is 1000 or 4006 (#3213)
* Event code 1001 should not get its sessionID reset

* Reset sessionID when close code is 1000 or 4006
2019-04-17 14:32:57 +01:00
Vlad Frangu
eb537b6f48 docs(WebSocketShard): mark non-nullable parameters as non-nullable (#3209)
* docs: Imagine having an optional nullable param

* docs: Another one
2019-04-15 20:17:27 +02:00
thomasxd24
8da141637c fix end method in VoiceBroadcast (#3194)
* fix end method in VoiceBroadcast

this.client is a ClientVoiceManager and thus its this.client.broadcasts  instead of this.client.voice.broascasts

* revert the voicebroadcast and pass this.client at clientvoice

* passed this.client
2019-04-11 21:34:12 +01:00
Vlad Frangu
89e27e5071 src: Make broadcasts work again (#3190) 2019-04-08 17:29:19 +01:00
SpaceEEC
f479afca82 src: Fix TypeError (#3187) 2019-04-08 14:21:48 +02:00
Vlad Frangu
70d4b4455b refactor(ClientVoiceManager): make public, remove Client#voiceConnections (#3186)
* docs: make voice public

* typings: Update typings to match the docs

* typings: ClientVoiceManager is nullable in Client

Co-Authored-By: vladfrangu <kingdgrizzle@gmail.com>

* typings: Mark client as readonly

Co-Authored-By: vladfrangu <kingdgrizzle@gmail.com>

* src: Make the client readonly

* src: Remove Client#voiceConnections getter in favor of ClientVoiceManager#connections
2019-04-08 14:20:53 +02:00
Vlad Frangu
982f48ce6a src: Fix TypeError 2019-04-07 10:57:11 +03:00
bdistin
5e9bd786d1 refactor(APIRequest): utilize URLSearchParams (#3180)
* utilize URLSearchParams

* options.query can be undefined/null

* oops

* remembered what I intended
2019-04-05 11:32:19 +02:00
Vlad Frangu
3f5161eb76 fix: Internal Sharding, this time fixed™ (#3140)
* src: WIP Internal Sharding refactor

* src: Refactor unavailable guild check
Co-Authored-By: kyranet <kyradiscord@gmail.com>

* src: More WIP Code
F in the chat to the old manager

* src: It should work but Discord says no.
Seriously why is this not working!

* fix: Inflator causing issues

* src: Finishing touches and typings

* misc: Proper debug message

* fix: Making things hidden needs writable: true as well

* fix: Sharding allowing multiple of the same shard, negative shards or strings

* fix: Again... edge cases
I love you guys .w.

* misc: Touchups

* misc: Better error?

* docs: Typo

* typings: Requested changes

* src: Requested changes

* src: Fix issues, validate provided shard options and more

* src: Forgot to remove the listener

* lint: eslint complaining

* fix: Setting shardCount to auto crashing the process

* misc: Requested changes

* typings: Correct typings for shardCount client option

* typings: Add invalidSession event to the shard and correct typings

* src: Minor docs adjustements, and code consistency between setHelloTimeout and setHeartbeatTimeout

* src: Don't block reconnect while creating shards
Might fix silent disconnects *again*

* src: Prevent reconnect from running if the Manager isn't READY
That way, if a shard dies while we're still spawning, it won't cause issues

* fix: Retry to reconnect if there's a network error going on.
The manager *should* keep reconnecting unless the token is invalid

* src: Enhance onClose handler for shards in the manager
- If the close code is between 1000 and 2000 (inclusive), you cannot resume
I tested this locally
- If there's a session ID still present, immediately try to resume
Faster resumes :papaBless:
Otherwise, the invalid session event will trigger and it'll handle accordingly

I swear if I see a SINGULAR Silent DC I'm yeeting

* src: Fix error check

* src: Make sure message exists on the error

* src: Used the wrong property for the shardQueue

* src: Make the hello timeout be made by the client
god help

* docs: Correct docs for WSEvents

* misc: Remove old events from the Events constant

* src: Throw the HTTP error if we don't get a 401

* typings: Can't forget about them

* src: Implement some more fail safes just in case
Seriously, better safe than sorry! Gotta failproof it completely
2019-04-01 09:43:45 +02:00
Amish Shah
b74a4356dd fix lint errors 2019-03-23 12:54:22 +00:00
Amish Shah
6adb0a6609 voice: add ability to delete broadcasts 2019-03-23 12:52:18 +00:00
Amish Shah
9a092b6e57 voice: rename createVoiceBroadcast to createBroadcast 2019-03-23 12:37:55 +00:00
Amish Shah
c8225631c9 voice: move broadcasts to client.voice 2019-03-23 12:36:53 +00:00
Amish Shah
3df56540e2 voice: add documentation to VoiceBroadcast 2019-03-23 12:22:55 +00:00
izexi
2341d13615 fix: messageReactionRemove not emitting for partial messages (#3125) 2019-03-19 20:32:11 +01:00
SpaceEEC
e62833b5e1 docs: mark getters as @ readonly 2019-03-19 19:59:45 +01:00
Amish Shah
efbbfbcec6 fix #3102 2019-02-20 19:15:33 +00:00
Amish Shah
6aa792f9ab voice: cleanup internals whether end() or destroy() is called 2019-02-19 13:16:48 +00:00
Amish Shah
4009986bc8 voice: destroy opus 2019-02-17 21:48:47 +00:00
Amish Shah
0564c5c777 voice: update prism 2019-02-14 16:57:26 +00:00
Amish Shah
5c3f5d7048 Partials (#3070)
* Remove GroupDMChannels

they sparked no joy

* Start partials for message deletion

* MessageUpdate partials

* Add partials as an opt-in client option

* Add fetch() to Message

* Message.author should never be undefined

* Fix channels being the wrong type

* Allow fetching channels

* Refactor and add reaction add partials

* Reaction remove partials

* Check for emoji first

* fix message fetching

janky

* User partials in audit logs

* refactor overwrite code

* guild member partials

* partials as a whitelist

* document GuildMember#fetch

* fix: check whether a structure is a partial, not whether cache is true

* typings: Updated for latest commit (#3075)

* partials: fix messageUpdate behaviour (now "old" message can be partial)

* partials: add warnings and docs

* partials: add partials to index.yml

* partials: tighten "partial" definitions

* partials: fix embed-only messages counting as partials
2019-02-13 17:39:39 +00:00
Amish Shah
8910fed729 voice: debug UDP (#3044) 2019-02-12 16:29:11 +00:00
Amish Shah
c362ba0dd5 voice: more debug 2019-02-11 18:37:33 +00:00
Amish Shah
fe51b4e89b voice: more debug information, correctly listen to vws 2019-02-11 18:28:37 +00:00
Amish Shah
375706beac voice: replace self.xyz events 2019-02-11 18:03:35 +00:00
Amish Shah
810b5a5f71 voice: more debug info 2019-02-11 17:57:56 +00:00
Amish Shah
283fc54ce4 More debug information 2019-02-11 17:39:19 +00:00
Amish Shah
a705edfd0d voice: more debug information 2019-02-11 17:22:17 +00:00
Amish Shah
aab3523fb5 voice: more debug information
#3074, #2979, #3044
2019-02-10 20:18:08 +00:00
Vlad Frangu
793341dbb4 fix: Sharding issues, silent disconnects and code cleanup (#2976)
* fix: Sharding bugs, silent disconnects and cleanup code

* typings

* fix: Destroy connecting with close code different from 1000
Per `If a client does not receive a heartbeat ack between its attempts at sending heartbeats, it should immediately terminate the connection with a non-1000 close code, reconnect, and attempt to resume.`

* misc: Wait x ms before reconnecting
Per https://discordapp.com/developers/docs/topics/gateway#resuming

* docs

* nit: docs

* misc: Prevent multiple calls to WebSocketManager#destroy

* fix: Implement destroying if you reset the token

* misc: Clear the WS packet queue on WebSocketShard#destroy
You can't send those packets anywhere anymore, so no point in keeping them

* fix: Handle session limits when reconnecting a full shard, cleanup

* misc: No need to create a new shard instance

* fix: closeSequence being null, thus emitting null on Client#resumed

* misc: Remove GUILD_SYNC Gateway handler and add missing dot to string

* misc: Close WS with code 4000 if we didn't get a heartbeat in time

As said in the Discord API server

* fix: Handle ready emitting in onPacket
Doesn't allow broken packets

* misc: Close the connection if Discord asks for a reconnect
Prevents double triggers

* testing: Prevent multiple reconnect attempts on a shard

Should fix some issues some people have had.

* fix: Prevent multiple reconnect calls on the shard, re-use conn to identify, remove reconnect function
Note: Closing the WS with 1000 makes the session invalid

* misc: Forgot to remove 2 unneeded setters

* docs: Wrong param docstring for WebSocketShard#destroy

* misc: Set status to reconnecting after destroying

* misc: Close connection with code 1000 on session invalidated
Allows us to cleanup the shard and do a full reconnect
Also remove identify wait delay, not used anywhere

* fix: Fix zlib crash on node
And with that, the PR is done!

* misc: Implement a reconnect queue
And that is all there was to be done in this PR.
Shards now queue up for a reconnect

* nit: Debug the queue after destroying

* docs: Make the invalidated event clearer

* lint: I'm good at my job

* docs

* docs: Make description for isReconnectingShards accurate
*can I stop finding issues, this PR is meant to be done*

* misc: Remove shard from bind params

* misc: Code re-ordering and cleanup
Resumes do not need to be queued up, as they do not count to the identify limit, and after some testing, they don't have the 5 second delay required, like in identify

* fix: Issues with token regeneration and shards not properly handling them
We close the ws connection with code 1000 if we get an invalid session payload,
that way we can queue the reconnects and handle any issues

* misc: Remove useless delays on session invalidated
They get handled by the rest of the code already

* lint

* misc: reset the sequence on Shard#destroy
This especially is a problem if you need to re-identify, as the sequence doesn't get set to the current one,
causing the sequence to be wrong

* fix: GitHub rebase and minor tweak
* Implement a 15 second timeout if shards don't connect till then
Should prevent shards that never reconnect

* revert: Make WebSocketShard#send and WebSocketManager#broadcast public

* typings: Set type to void instead of undefined

* docs: Requested Changes
2019-02-10 16:28:03 +00:00
Amish Shah
f826c9c75e voice: workaround for receiving audio
(#2929 and discordapp/discord-api-docs#808)
2019-02-05 10:26:16 +00:00
Marcel Menzel
f2ed93c08a fix(WebSocketShard): report correct resumed event count (#3019)
This PR attempts to fix the reported resumed event count in the debug output (where it is always displayed only as 1 event replayed) and in the emitted `resumed` event, where it passed the current sequence instead of passing the actual replayed event count (which was an utopic high number for smaller bots on resume).
2019-02-02 11:28:45 +01:00