Commit Graph

3805 Commits

Author SHA1 Message Date
SpaceEEC
32a432f4a5 cleanup(ShardClientUtil): rename id to ids 2019-04-01 13:46:27 +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
Ryan Munro
4b6e8fcab5 typings(Collection): add missing thisArg to partition (#3167) 2019-04-01 09:36:03 +02:00
Schuyler Cebulskie
04fa56d0c0 Improve structure extension errors 2019-03-24 16:45:34 -04: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
9b2bf03ff6 feat(MessageStore): add cache parameter to fetchPinned() (#3154)
* add cache param to MessageStore#fetchPinned()

* typings for cache param

* set cache to true by default
2019-03-19 20:35:58 +01: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
Ryan Munro
df1889ab49 cleanup(Guild): removed fetchAuditLogs' "after" option (#3142)
* Removed code and documentation for Guild.fetchAuditLogs "after" option

* Also removed the option from typings
2019-03-12 19:14:32 +01:00
bdistin
1673b6f8f5 fix(APIMessage): edit shouldn't remove content (#3129)
* edit shouldn't remove content

If undefined is passed to the api, content isn't removed in such a case where you are only editing the embed.

* fix a related doc string

* update typings

* requested changes
2019-03-08 17:57:59 +01:00
Antonio Román
132788937a src: add missing events in constants (#3124)
* src: Add missing events in constants

* fix: Restore 'use strict';
2019-03-05 17:18:11 +01:00
Kamran Mackey
1207c243d1 typings(Guild): add missing defaultRole property (#3126)
* [typings] Fix missing defaultRole property under Guild.

Signed-off-by: Kamran Mackey <kamranm1200@gmail.com>

* [typings] Added missing readonly identifier.

Signed-off-by: Kamran Mackey <kamranm1200@gmail.com>
2019-03-04 20:32:15 +01:00
SpaceEEC
579283dfe9 fix(Role): proper undefined check for data.permission when editing 2019-03-02 21:58:40 +01:00
bdistin
fe5563e158 refactor(User): avoid invoking dmChannel getter more than once per method (#3108)
also refactors to async methods
2019-02-24 09:37:10 +01:00
Linn Dahlgren
7006f00ae4 feat(MessageEmbed): add missing proxyURL property to video (#3109)
* Added missing property to MessageEmbed.video

* Updated typings for MessageEmbed.video
2019-02-24 09:27:57 +01:00
Kyra
bc0a761e22 typings: Convert types to interfaces where applicable (#3068) 2019-02-23 22:14:09 -06:00
Linn Dahlgren
4d3f76656a docs(MessageEmbed): add missing type value (#3106) 2019-02-23 10:05:04 +01:00
Amish Shah
73be952406 use official release of prism 2019-02-21 11:56:46 +00: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
SpaceEEC
4289b18ab2 docs(GuildMember): add missing @name to document user property
Fixes #3090
2019-02-14 11:19:05 +01: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
Kyra
5c19ad7252 cleanup: Error messages cleanup (#3079)
Removed keys that return zero occurrences in the library's source code
2019-02-12 08:13:15 +00:00
Kyra
0c7a618f10 cleanup: remove unused members of classes (#3078)
* cleanup: Remove unused members of classes

* typings: Remove hit from Message
2019-02-11 20:33:13 +01: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
Kyra
ab55acffdb webpack: Fix module warning when building (#3076)
Warning:
```
WARNING in ./src/client/Client.js
Module not found: Error: Can't resolve 'worker_threads' in 'D:\Repositories\discordjs\discord.js\src\client'
 @ ./src/client/Client.js
 @ ./src/index.js
```
2019-02-11 16:29:20 +00:00
Kyra
0c5b9c6870 chore(deps): Updated all required, peer, and development dependencies (#3073)
* chore(deps): Updated all required, peer, and development dependencies

And engines.node to require 10

* chore(peerDeps): Updated uws to 11.149.1

Clarified my doubts with iCrawl
2019-02-11 07:41:37 +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
SpaceEEC
7324a993ed fix: ensure VIEW_CHANNEL permissions before trying to join (#3046)
* fix: ensure VIEW_CHANNEL permissions before joining

* nit(GuildChannel): remove the redundant truthy check
2019-02-10 15:21:59 +00:00
Atlas
ff95e587cb Better wording (#3032) 2019-02-09 23:53:47 +00:00
Kyra
d057a5040c ci: Test in Node.js 10 and 11, deploy with Node.js 10 (#3069) 2019-02-09 23:51:23 +00:00
Kyra
9449f8df8f cleanup(GuildMember{RoleStore}): Rewrite to async/await (#3072)
- Fixed a bug where `GuildMemberRoleStore#{add,remove}` would create a rejected promise inside a promise, instead of rejecting the first one.
- Fixed a bug where `GuildMember#edit` with a specified unknown channel would throw synchronously, instead of rejecting asynchronously.
2019-02-09 17:20:10 +00:00
Kyra
c432591113 feat(RoleStore, ChannelStore): fetch() method (#3071)
* feat({Role,Channel}Store): fetch method

* docs: Add usage examples to the new methods

* misc: Add note of why we are fetching all roles even for a single one
2019-02-09 15:07:31 +00:00
Kyra
ae7269088b typings(ShardClientUtil): fix id property type (#3054)
Ref: d98d464d74/src/sharding/ShardClientUtil.js (L50)
2019-02-06 18:15:05 +01:00
Amish Shah
f826c9c75e voice: workaround for receiving audio
(#2929 and discordapp/discord-api-docs#808)
2019-02-05 10:26:16 +00:00
Kyra
d98d464d74 typings(GuildCreateChannelOptions): added missing properties (#3052)
* typings(GuildCreateChannelOptions): Added missing properties

* typings: Added `GuildChannelCloneOptions`
2019-02-04 17:57:13 +01:00
Kyra
dd8ba00af4 misc(index): export HTTPError class (#3051) 2019-02-04 16:44:21 +01:00