Commit Graph

47 Commits

Author SHA1 Message Date
thepheer
12187efdbd feat(DataResolver): prefer streams over buffers (#4075)
* feat(DataResolver): prefer streams over buffers

* feat(DataResolver): add `resolveFileAsBuffer`

Add `resolveFileAsBuffer` to use it in `resolveImage` which still requires Buffers to work.

* fix(DataResolver): make sure `resolveFile` always returns a Promise

* refactor(DataResolver): use for-await-of

* fix(DataResolver): use forked form-data which supports custom streams

* fix(APIRequest): use forked form-data in code too

Co-authored-by: - <5144598+-@users.noreply.github.com>
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
2020-04-17 12:03:50 +02:00
SpaceEEC
7b38f46caf fix(RequestHandler): a global timeout implies limited (#3950) 2020-03-17 09:02:51 +01:00
SpaceEEC
a4f7e07b3b fix(APIRequest): only use form data when actually sending files (#3917) 2020-03-08 19:28:19 +01:00
Crawl
c065156a88 chore: consistency/prettier (#3852)
* chore: consistency/prettier

* chore: rebase

* chore: rebase

* chore: include typings

* fix: include typings file in prettier lint-staged
2020-02-29 14:35:57 +01:00
Crawl
3a0470b45c chore(deps): update deps and fix lint (#3833) 2020-02-24 23:14:31 +01:00
Gryffon Bellish
100360705a fix(APIRouter): use proper symbol for util.inspect (#3589) 2019-11-20 18:11:23 +01:00
bdistin
278f185b64 fix(rate-limits): reactions buckets need to be shared with sub-… (#3439) 2019-09-10 17:29:44 +02:00
Saya
e4309b23d5 feat: abort Requests that takes a lot of time to resolve (#3327)
* Add Request Timeout

* Add abort controller in packages

* Fix Lint Error.

* Fix Lint Errors

* Make Timeout Customizable & use finally

* Fixed a minor issue

* Fix eslint

* Update request timeout to use d.js client timeout methods.
2019-08-19 18:55:07 +02:00
Amish Shah
f79f024343 fix: bots being unable to connect 2019-08-12 21:40:26 +01:00
Reseq64
6be5051f92 typo(RequestHandler): fix spelling of 'requests' (#3196)
Removed the additional "s" to "requessts"
2019-04-10 17:07:50 +02:00
SpaceEEC
00eb7e325a fix(ApiRequest): filter out null query values
Fixes #3183
2019-04-05 16:32:50 +02: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
SpaceEEC
089f65fd2a fix(RequestHandler): pass HTTPError pass path instead of route as path 2019-04-03 22:45:51 +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
Gus Caplan
42505b78c1 chore: add strict mode (#2974) 2018-12-03 15:19:10 -06:00
Lewdcario
e189c1b728 fix: revert #2744
see #2848, fixes issues with stack not displaying correctly
2018-10-15 02:08:49 -05:00
SpaceEEC
ead99a53b7 fix(HTTPError): the path property should actually be the path 2018-09-02 14:57:36 +02:00
Isabella
be4d6f9dc3 feat: add ClientOptions#retryLimit (#2805)
* feat: add ClientOptions#retryLimit

* hydra needs to learn how to code right

* a default would probably help

* move incrementor & update comment

* clarify docs on Infinity
2018-09-01 04:51:35 +02:00
Lewdcario
f75b80d96b docs: add docstring to HTTPError 2018-08-30 16:31:22 -06:00
Kyra
989c365ef1 fix: Better global ratelimit management (#2801)
* fix: better global ratelimit handling in RequestHandler

fix: Remove useless line

fix: Better global ratelimit management

* refactor: Changed RESTManager#globallyRateLimited to be a getter

* refactor: Remove RESTManager#globallyRateLimited getter

* docs: Updated comments to reflect latest changes
2018-08-28 18:28:21 -05:00
bdistin
f326fe67b1 fix: reactions ratelimits (#2795)
* each reaction doesn't have it's own ratelimit

* fix hard-coded reset for reacting
2018-08-28 18:25:38 -05:00
Isabella
13f46b924b refactor: clean up rate limit handling (#2694)
* refactor: clean up rate limit handling

* requested changes

* remove request mode option

* fix dupe requests

* hardcode reaction ratelimits

* suggested changes

* fix small thing

* re-add restTimeOffset

* move restTimeOffset a bit

* i swear i know english its my native language ok

* requested changes

* fix: a bit *too* pre-emptive with ratelimits, now less so

* fix: dapi error shoudl reject with path

* fix: make errors in execute catchable

* fix promise return

* rebase is hard
2018-08-24 06:29:44 +02:00
SpaceEEC
d91deefd79 fix(RequestHandler): DiscordAPIError#path should be the path, not the route 2018-08-21 12:05:33 +02:00
Kyra
3f81b613d8 fix: Handle async stacks correctly (#2744)
* fix: Capture stack traces in APIRouter to preserve async stack

* fix: Handle the stack trace better

* fix: Check if error is an instance of Error (5XX rejects with Result)

* fix: Error.captureStackTrace is not supported in all browsers
2018-08-16 19:51:21 +01:00
bdistin
5afd77ab73 refactor: remove user bot methods (#2559)
* [WIP] Remove user bots

* more backend userbot removal

* Add mfaEnabled back

* revert client presences store removal

* partially revert getAuth changes

* remove more no longer used children of ClientUserGuildSettings

* fix a bug with this pr and TextBasedChannel.applyToClass

* remove a syncGuilds reference

* more user bot data handling

* various guildSync cleanup

* bots can't call logout

Had the user/bot portions of the code mixed up. Though, does this need to be a promise anymore?

* make ClientManager#destroy() sync

It nolonger needs to be a promise, and nothing depended on it being a promise that I can tell.

* requested change

* Fix massive error

* no longer used as it's userbot only
2018-07-25 22:14:23 -04:00
Lewdcario
2694c0d442 fix(RequestHandler): provide proper route and method 2018-06-29 15:13:03 -05:00
Lewdcario
92e2c3c7fd fix: instantiate constructors before using those properties 2018-06-29 15:12:52 -05:00
bdistin
58e5017159 fix: ratelimits (#2615)
* Add timeDifference calcs back into ratelimits

And fix x-ratelimit-reset is in seconds, not ms: https://puu.sh/AIXxY/9b3989b248.png

* mutate reset time with date header instead

* fix defaulting of reset and remaining

if the reset header is not available, then the reset time should be Date.now() instead of the difference between the date header and Date.now()

If the date header is null, fall back to Date.now() since it's the best we can do (this should never happen, but safer to handle it just in case)

if remaining is 0 we don't want to default it back to 1 since 0 is falsy
2018-06-23 16:08:40 -05:00
Will Nelson
594363a05e fix response parsing (#2614)
* fix response parsing

* rfc: better parseResponse function
2018-06-21 00:11:47 +02:00
Will Nelson
5e011dbc11 switch to node-fetch (#2587)
* switch to node-fetch

* remove useless var declaration

* remove method uppercasing

* rework concurrency

* Revert "rework concurrency"

This reverts commit ef6aa2697e.

* fix headers
2018-06-19 20:10:55 +02:00
bdistin
99bd355522 refactor: RESTManager handlers to use collection (#2539) 2018-06-10 05:45:34 +02:00
SpaceEEC
14aab1be38 fix(RequestHandler): only retry once on 5xx (#2471) 2018-05-25 17:33:17 +02:00
Lewdcario
75747f5b18 fix: RequestManager getting stuck on global ratelimit
fixes #2550
2018-05-14 22:55:50 -05:00
Kyra
62605c4470 feat(DiscordAPIError): add method property (#2530) 2018-05-03 08:01:27 +02:00
Amish Shah
bd83bb9fd6 refactor: improve sweep performance 2018-05-02 18:09:51 +01:00
Amish Shah
27a0f48441 refactor: tidy up _inactive check 2018-05-02 18:04:47 +01:00
Amish Shah
b5f37728a7 feature: allow sweeping of inactive request buckets 2018-05-02 17:57:48 +01:00
1Computer1
01f1f1b58e Fix query string on requests after ratelimited (#2215)
* Fix querystring being appended multiple times when ratelimited

* Better way?

* Better better way

* Fix empty queries
2018-01-04 01:17:15 +01:00
Frangu Vlad
0cd4a92fb8 docs: Fixed some missing docstrings or incorrect return types (#2093)
* Fix some missing doc strings
Mainly just readonly tags

* Return an error when guild#allowDMs is ran from a bot account, and fix some return types

* WebhookClient implements Webhook, doesn't extend it

* Fix Client#rateLimit docs not showing what it returns

Cause I wanted to handle this event only to see no return props 🤔

* Actually make Client#rateLimit show the right info

Its an object with all the info
2017-11-17 14:20:57 +01:00
Gus Caplan
cd54e9317f Time Difference in REST (#2057) 2017-10-27 14:36:53 +01:00
Gus Caplan
ee1d4c53f2 Add rateLimit event (#2019)
* add ratelimited event

* add some useful props

* death

* more death

* Update tester1000.js

* Update RequestHandler.js
2017-10-24 21:07:21 +01:00
Gus Caplan
296046dbc6 remove ua manager (#2015) 2017-10-19 07:11:07 +02:00
SpaceEEC
68a30584db refactor: remove redundant Client#rest and obsolete RESTManager#destroy (#2022) 2017-10-11 02:29:50 +02:00
Gus Caplan
27ccad1f1c tinify webpacks (#1975)
* tinify webpack

* meme

* fix long version

* more changes

* even smoler

* fix up logic

* fix build

* undo changes to user agent manager because its not webpack'd anymore

* the heck

* fix stupid

* clean up browser rules

* typo
2017-09-26 07:18:12 +02:00
Gus Caplan
4d4d2f2db7 add agent support (#1973) 2017-09-25 20:46:19 +02:00
SpaceEEC
ec4c98704f refactor: make use of destructuring for Constants (#1942) 2017-09-16 20:31:36 +02:00
Gus Caplan
18e3801bb7 lots of important stuff (#1883)
* lots of important stuff

* Update Constants.js
2017-09-04 17:49:44 +02:00