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(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
* 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>
Fixed:
- lastShardId & totalShards when starting a bot without pre-set `gatewayBot` information
Removed:
- Debug handling of close code 1000 for shards
* perf(plugins/helpers,rest,site,template)!: uppercase rest methods
There is no need for us to pass the methods in lower case and then use the `toUpperCase()` method everywhere. Therefore this PR changes every lowercase method to be uppercase (eg. `"get"` => `"GET"`).
* template is old version
* refactor(bot,helpers,plugins,rest,util)!: improve rest route handling
- rename endpoints constant to routes
- simplify routes code by removing bases and function calls
- url query params can now be passed to the route functions
* style: deno fmt
* fix base stuff
* suggestions
Added:
- `convertRestError` function so you can edit the error stack better/add additional handling
- `Collection#forceSet` method which ignores the `maxSize` limit of the collection
Changed:
- Intent calculation now needs to be done manually (eg. `Intents.Guilds | Intents.GuildMessages`) **BREAKING**
Fixed:
- `ApplicationCommandOption#required` is optional
- `createInvite` sending the wrong value for `target_application_id`
- `editApplicationCommandPermissions` needs a bearer token to access the related endpoint **BREAKING**
- `sendInteractionResponse` not uploading files
Removed:
- leftover console.log in the `spawnShards` and `processGlobalQueue` functions
* fix(rest)!: `editApplicationCommandPermissions`
- add `bearerToken` option
- add headers to `RestPayload`
- remove `batchEditApplicationCommandPermissions` since the related endpoint has been removed
* fix header prefix
This changes the calculation of intents to be manual to the dev.
This is to improve overall consistency of our code base, also it is not a big drawback for users since intents are usually done once and then never (seldom) touched again.
This changes the calculation of intents to be manual to the dev.
This is to improve overall consistency of our code base, also it is not a big drawback for users since intents are usually done once and then never (seldom) touched again.
Currenty we do not specify out repository in our `package.json` for npm.
This changes that to target our main repository.
Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
* feat(helpers,types): slash command localization
Discord has documented the slash command localization feature now.
This adds the full functionality for those to Discordeno.
Additionally a `Locales` has also been added to allow for better typing.
Reference: https://github.com/discord/discord-api-docs/pull/4653
* suggestion
* better locales type
* f
* fix serializing
* stupid direct pushes
* b
* feat(helpers,types)!: add guild template transformer
This adds a template transformer. Also this fixes incorrect type definitions regarding templates.
Breaking Change: The previously called `Template` interface which was used for creating templates has been renamed to `CreateTemplate`
* fmt
* forgot to add this
* use data
GitHub workflows cannot trigger another workflow. Due to this the npm workflow currently did not run on a version constant update.
Since we will only publish with a version constant update there should be no problem when we move the npm release in there.
Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>