Currently the route definitions make `createRestManager` massive. Moving them to their own creator function makes it a bit easier to handle.
Also `sessionInfo` has been removed since it's just an alias to `gatewayBot`. Instead `gatewayBot` should be used.
It has been removed since the routes are mainly used internally in the lib. Almost no one should need to touch them outside, but if they do they should know how routes are called.
* refactor(rest): remove falsy token check
This is in favour for interaction only bots, which still need rest but cannot provide a valid bot token.
If you want to use rest for your normal bot it should be your own responsibility to pass a valid token.
Further more `applicationId` is now a required property since we cannot extract the id from the token anymore.
* forgot to commit that
* fix error
* make appid optional again
* app id throw error if undefined
* fix test
Currently we use a double negation in the code which makes it harder to understand what it actually does.
Therefore the check has been changed to be understood easier.
* refactor(rest): interaction handling
Currently some interaction handling uses `sendRequest` directly.
This adds the `runThroughQueue` option, which prevents the request to be handled by a queue effectively giving the same effect as using `sendRequest` directly.
This prevents code repetition and supports future endpoints which might not have a rate limit too.
Further more all interaction related endpoints have now been set to not send the bots authorization header.
* fix invalid file
* fix eslint
* fix: followups have a rate limit
* fix awaiting
* refactor!(rest): rest proxy attachment sending
Currently attachments get encoded as base64 before being send to the proxy. This is not really necessary, instead we can just send `FormData` to the proxy.
* fix lint
* fix(rest, types)!: support auditlog reason
Improved the consistency by separating the audit log reason to an optional function parameter.
Also added support for 100% documented reason endpoints.
* missing stuff
* fix this
* fix e3e
* fix(transformers): message transformer using different style
* fix: more bench tests
* fix(bench): token can not be empty
* more desired props
* fix: bug on message.id props
* fix: transfomrer errors on bench
---------
Co-authored-by: Jonathan Ho <heiheiho000@gmail.com>
* fix(bot,rest,types)!: attachment sending
* apply code suggestions
* forgot to add that
* this should not be there i guess
* maybe spell it right
* actually revert the attachments rename
* Change how method gets passed
* more stuff
* improve function name
* ci: test
* ci: add script
* ci: change to js
* ci: test
* ci: fix error
* ci: fix script
* chore: add benchmark
* ci: fix need input
* fix: read file with dir
* ci: change push to trigger on main only
* ci: try new method
* ci: fix "true"
* chore: fix set output
* fix: set output
* ci: increase number of try
* chore: clean up dir
* fix needs
* bench: add memory bench
* bench: import memory bench
* bench: fix v19 syntax
* bench: more fix
* bench: add filter
* bench: minor fix
* ci: read file in sync
* chore: yarn install
* chore: add db to ignore
* refactor(bench): use loader
* bench: only bench on one event
* bench: add type to db event
* chore(bench): better type
* bench: add rest simplifyUrl bench
* chore: add microtime
* refactor: add fall back
* Revert "ci: change push to trigger on main only"
This reverts commit 04df971025.
* chore: yarn install
* ci: trigger push event only on main branch
* chore(bench): use node-fetch
* refactor(bench): make it work with other function and event
* chore(bench): better name
* fix(utils): leaky bucket slow refill test
* fix the fix
* remove left comments
* Update packages/utils/tests/bucket.spec.ts
Co-authored-by: Jonathan Ho <heiheiho000@gmail.com>
---------
Co-authored-by: Jonathan Ho <heiheiho000@gmail.com>
* refactor(rest): simplify `manager.simplifyUrl`
The changes improve readability and performance by a small margin.
* refactor(rest)!: improve `RestManager.createRequest`
- AuditLog Reasons: options.body.reason => options.reason
- options.body can now be FormData
* forgot those
* suggestions
---------
Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>