Commit Graph

3768 Commits

Author SHA1 Message Date
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
Isabella
75e264da57 feat: Presence#clientStatus (#2997)
* feat: Presence#clientStatus

* fix Presence#equals check

* fix typings

* vlad changes

* presence consistency docs

* fix docs

* fix big docs fail
2019-02-02 20:29:47 +01:00
Rattmann (fallen)
1db78994dd feat: MessageEmbed#length (#3003)
* add MessageEmbed#length

* update typings (+MessageEmbed#length)

* eslint: L181 (max line length), L183 (missing semi)

* eslint: L181 (trailing space)
2019-02-02 20:29:10 +01:00
SpaceEEC
db3ae0159b docs(Structures): note about extending prior to instantiating client (#2884) 2019-02-02 20:28:24 +01: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
Kyra
2dcdc798ac typings: add missing ImageSize numbers (#3045)
To match the JS typedef: https://discord.js.org/#/docs/main/master/typedef/ImageURLOptions
2019-02-02 10:42:13 +01:00
Anthony Collier
3dff5058f0 docs(Examples): fix usage of removed overload of Collection#find (#3027) 2019-01-21 17:22:24 +01:00
Isabella
8230255c68 fix(ShardClientUtil#id): erroneously reporting as an array 2019-01-15 01:45:29 -06:00
SpaceEEC
28db527370 docs(Guild): use 'updated' variable in example for setRegion 2019-01-10 16:54:02 +01:00
SpaceEEC
840d22f892 docs(Webhook): add mising '@name' to Webhook#token's docstring 2018-12-30 12:52:33 +01:00
Amish Shah
0bde9ca2c5 voice: set seek parameter before input (#2993) 2018-12-27 18:05:54 +00:00
Kyra
8a76cc5c72 typings(TextBasedChannel): add Snowflake[] overload to bulkDelete (#3001)
* typings: Add `string[]` overload to bulkDelete

* misc: Requested changes
2018-12-25 22:00:46 +01:00
Lucas Kellar
8286d1a0fc typings(SnowflakeUtil): add optional "timestamp" parameter to generate (#2998) 2018-12-23 23:16:28 +01:00
SpaceEEC
21ec03140f feat(GuildChannelStore): add support for create to accept a position (#2965) 2018-12-22 08:50:33 +01:00
Will Nelson
5cbdf38028 fix(WebSocketShard): add websocket send error handling (#2981)
* websocket send error handling

* fix: emit only when error is present

* refactor: use an if instead
2018-12-22 08:49:56 +01:00
August
b5d5c699e6 fix: guildBanRemove event name (#2983)
- "Events.GUILD_BAN_REMOVEGUILD_BAN_REMOVE" -> "Events.GUILD_BAN_REMOVE"
2018-12-09 09:30:46 +01:00
Gus Caplan
42505b78c1 chore: add strict mode (#2974) 2018-12-03 15:19:10 -06:00
SpaceEEC
ecaec29380 fix(Util): throw an explicit error if a chunk exceeds the max length (#2936)
* fix(Util): throw an explicit error if a chunk exceeds the max length

* refactor(Util): consolidate both errors in splitMessage into one

* revert(Messages): do not unnecessarily change the error code

* revert(Messages): do not remove the word 'the'
2018-11-27 21:42:28 +01:00
Darqam
23a16c3a73 fix(GuildChannel): add explicit channel resolve error to member edit (#2958)
* Add explicit error to setting invalid voice channel

* restrict to guild

Co-Authored-By: Darqam <anhim2@gmail.com>

* add a more explicit error and channel type check

* bad tab
2018-11-27 21:41:34 +01:00
SpaceEEC
fd21bbb7bf docs: move event docstrings to the emitting line of code 2018-11-27 21:28:36 +01:00
Skillz4Killz
1d1b3f25e1 docs: add documentation for Client#channelCreate (#2967) 2018-11-27 21:12:25 +01:00
SpaceEEC
a8b47a7a6c feat(GuildChannelStore): add support for create to accept a position 2018-11-23 19:46:11 +01:00
Frangu Vlad
9085138f0d fix: Sharding Issues & Cleanup (#2952)
* fix: Sharding causing constant heartbeat / identify spam

* misc: Remove wait param in connect

* misc: Wait 2.5 seconds before sending identify again if session is resumable

* misc: Remove useless destroy call

* nit: Capitalization

* fix: Identify on HELLO not connectionOpen

* misc: Add different intervals for identify after invalid session
- 2500 if we couldn't resume in time
- 5000 if we didn't have a session ID (per the docs on identify, that a client can only connect every 5 seconds)
- Otherwise, just identify again

* misc: Only clear heartbeat if shard is fully dead

Reconnect clears it otherwise

* fix: Accessing .length on a Collection
2018-11-21 13:42:37 -06:00
Crawl
377ecd73ea docs(GuildChannel): fix doc string for clone method 2018-11-20 16:42:27 +01:00
SpaceEEC
d92ee2ff99 feat(GuildChannel): allow to set all options when cloning (#2937) 2018-11-17 15:43:04 +01:00
Charalampos Fanoulis
81ff5075e4 chore: remove user account checkbox from bug report template 2018-11-17 15:41:12 +01:00
Yukine
e793338d74 fix: ShardClientUtil#count and ShardClientUtil#id typedef (#2956) 2018-11-16 22:46:02 -06:00
Kyra
54aff3191e feat(Constants): add error code 50020 (#2953)
* feat(Constants): Add error code 50020

Which is throw when using the vanity-url endpoint: https://github.com/discordapp/discord-api-docs/pull/748/

* docs: Document the new code
2018-11-16 16:55:15 +01:00
Amish Shah
2d68e837e5 voice: fix receiver null on immediate voiceStateUpdate 2018-11-15 21:38:02 +00:00
Lewdcario
3418b5a1a2 docs: restore Client#error docs that went missing 2018-11-06 14:59:02 -06:00
Lewdcario
6b886b0aba typings: add Guild#shard and Guild#shardID 2018-11-06 11:23:17 -06:00
Lewdcario
08002d0576 fix: Client#userUpdate receiving wrong packet 2018-11-05 18:24:50 -06:00
Lewdcario
b59c75e402 docs: add missing docstring for Client#guildDelete 2018-11-05 13:29:07 -06:00
Souji
905f1c3262 docs: add missing docstring for Client#userUpdate (#2930)
* docs: add missing docstring for Client#userUpdate

* docs: indentn't

* docs: indentn't 2
2018-11-05 17:46:47 +01:00
Lewdcario
7796cb5d05 fix: Client#raw emitting twice 2018-11-04 23:26:40 -06:00
Lewdcario
be0d1cd663 fix: Client#shards not being set properly 2018-11-04 23:25:54 -06:00
Isabella
f3cad81f53 feat: Internal sharding (#2902)
* internal sharding

* ready event

* the square deal

* the new deal

* the second new deal

* add actual documentation

* the new freedom

* the great society

* federal intervention

* some of requested changes

* i ran out of things to call these

* destroy this

* fix: Client#uptime went missing

* fix(Client): destroy the client on login failure

This may happen duo invalid sharding config / invalid token / user requested destroy

* fix(Client): reject login promise when the client is destroyed before ready

* fix(WebSocketManager): remove redundancy in destroy method (#2491)

* typo(ErrorMessages): duo -> duo to

* typo(ErrorMessages): duo -> due

* fix: docs and options

* docs(WebSocketManager): WebSockethard -> WebSocketShard (#2502)

* fix(ClientUser): lazily load to account for extended user structure (#2501)

* docs(WebSocketShard): document class to make it visible in documentation (#2504)

* fix: WebSocketShard#reconnect

* fix: presenceUpdate & userUpdate
* presenceUpdate wasn't really being handled at all
* userUpdate handled incorrectly because as of v7 in the Discord API, it comes inside presenceUpdate

* re-add raw event

* member is now part of message create payload

* feat: Add functionality to support multiple servers with different shards (#2395)

* Added functionallity to spawn multiple sharding managers due to adding start and end shards

* Small fixes and limiting shard amount to max recommended

* Forgot a check in spawn()

* Fixed indentation

* Removed optiosn object documentation for totalShards

* More fixes and a check that the startShard + amount doesnt go over the recommended shard amount

* fix getting max recommended

* Removed async from constructor (my fault)

* Changed start and end shard to a shardList or "auto" + fixed some brainfarts with isNaN

* Changed the loop and totalShard count calculation

* shards are actually 0 based

* Fixed a problem with the gateway and handled some range errors and type errors

* Changed Number.isNan to isNaN and changed a few Integer checks to use Number.isInteger

* Added check if shardList contains smth greater than totalShards; made spawn use totalShards again; shardList will be ignored and rebuild if totalShards is 'auto'; fixed docs

* ShardingManager#spawn now uses a for..of loop; fixed the if statement inside the new for..of loop to still work as intended; made the totalShards be set to a new amount if smth manual is put into ShardingManager#spawn just like before; Fixed some spelling

* internal sharding

* ready event

* the square deal

* the new deal

* the second new deal

* add actual documentation

* the new freedom

* the great society

* federal intervention

* some of requested changes

* i ran out of things to call these

* destroy this

* fix: Client#uptime went missing

* fix(Client): destroy the client on login failure

This may happen duo invalid sharding config / invalid token / user requested destroy

* fix(Client): reject login promise when the client is destroyed before ready

* fix(WebSocketManager): remove redundancy in destroy method (#2491)

* typo(ErrorMessages): duo -> duo to

* typo(ErrorMessages): duo -> due

* fix: docs and options

* docs(WebSocketManager): WebSockethard -> WebSocketShard (#2502)

* fix(ClientUser): lazily load to account for extended user structure (#2501)

* docs(WebSocketShard): document class to make it visible in documentation (#2504)

* fix: WebSocketShard#reconnect

* fix: presenceUpdate & userUpdate
* presenceUpdate wasn't really being handled at all
* userUpdate handled incorrectly because as of v7 in the Discord API, it comes inside presenceUpdate

* Internal Sharding adaptation

Adapted to internal sharding
Fixed a bug where non ready invalidated sessions wouldnt respawn

* Fixed shardCount not retrieving

* Fixing style

removed unnecessary parenthesis

* Fixing and rebasing

lets hope i didnt dun hecklered it

* Fixing my own retardation

* Thanks git rebase

* fix: assigning member in message create payload

* fix: resumes

* fix: IS wont give up reconnecting now

* docs: add missing docs mostly

* fix: found lost methods

* fix: WebSocketManager#broadcast check if shard exists

* fix: ShardClientUtil#id returning undefined

* feat: handle new session rate limits (#2796)

* feat: handle new session rate limits

* i have no idea what i was doing last night

* fix if statement weirdness

* fix: re-add presence parsing from ClientOptions (#2893)

* resolve conflicts

* typings: missing typings

* re-add missing linter rule

* fix: replacing ClientUser wrongly

* address unecessary performance waste

* docs: missing disconnect event

* fix(typings): Fix 2 issues with typings (#2909)

* (Typings) Update typings to reflect current ClientOptions

* fix(Typings) fixes a bug with Websockets and DOM Types

* fix travis

* feat: allow setting presence per shard

* add WebSocketManager#shardX events

* adjust typings, docs and performance issues

* readjust shard events, now provide shardId parameter instead

* fix: ready event should check shardCount, not actualShardCount

* fix: re-add replayed parameter of Client#resume

* fix(Sharding): fixes several things in Internal Sharding (#2914)

* fix(Sharding) fixes several things in Internal Sharding

* add default value for shards property

* better implement checking for shards array

* fix travis & some casing

* split shard count into 2 words

* update to latest Internal Sharding, fix requested changes

* make sure totalShardCount is a number

* fix comment

* fix small typo

* dynamically set totalShardCount if either shards or shardCount is provided

* consistency: rename shardID to shardId

* remove Client#shardIds

* fix: typo in GuildIntegrationsUpdate handler

* fix: incorrect packet data being passed in some events (#2919)

* fix: edgecase of ShardingManager and totalShardCount (#2918)

* fix: Client#userUpdate being passed wrong parameter
and fix a potential edgecase of returning null in ClientUser#edit from this event

* fix consistency and typings issues

* consistency: shardId instances renamed to shardID

* typings: fix typings regarding WebSocket

* style(.eslintrc): remove additional whitespace

* fix(Client): remove ondisconnect handler on timeout

* docs(BaseClient): fix typo of Immediate

* nitpick: typings, private fields and methods

* typo: improve grammar a bit

* fix: error assigning client in WebSocketManager

* typo: actually spell milliseconds properly
2018-11-03 13:21:23 -05:00
Schuyler Cebulskie
18f065867c Fix #2924 with a bandage (Node typings not updated) 2018-11-03 13:09:56 -04:00