* fix(types): make value of emoji property in DiscordButtonComponent and DiscordSelectOption partial
* fix: type error
* don't partial tranformer
* undo partial in EmojiToggles
* refactor(bot)!: setup desired properties for all transformers
SetupDesiredProps when is given an object that does not corrispond to a transformer object that supports desired properties will behave like TransformProperty on the entire object as when it tries to get the properties for said object it will find `never` as the props and for `IsKeyDesired` a props of `never` means that all props are desired.
* Use Equals helper, clean up a bit the code
* Explicit the IsKeyDesired TProps never behavior
* fix(bot): Bug with return type in functions
* fix(bot)!: Split DiscordSelectComponent into specific select components
And add missing resolved property from the responses, since this now correctly transformers the responses, resolved has to be added.
The reverse transformer does not transform resolved as it requires a bunch of others, such as a user, role, message reverse transformers etc.
* Apply suggestions from code review
Co-authored-by: Awesome Stickz <awesome@stickz.dev>
* Update permissions for community invites
Use payload_json for invite creation with file upload
The TODO in INVITE_CREATE is to be done after #4436 gets merged as it splits the transformer logic between gateway and the normal invite object, placing the event transformation code in the event itself
* Community invites breaking changes
* refactor(bot)!: setup desired properties for all transformers
SetupDesiredProps when is given an object that does not corrispond to a transformer object that supports desired properties will behave like TransformProperty on the entire object as when it tries to get the properties for said object it will find `never` as the props and for `IsKeyDesired` a props of `never` means that all props are desired.
* Use Equals helper, clean up a bit the code
* Explicit the IsKeyDesired TProps never behavior
* fix(bot): Bug with return type in functions
* refactor(bot)!: setup desired properties for all transformers
SetupDesiredProps when is given an object that does not corrispond to a transformer object that supports desired properties will behave like TransformProperty on the entire object as when it tries to get the properties for said object it will find `never` as the props and for `IsKeyDesired` a props of `never` means that all props are desired.
* Use Equals helper, clean up a bit the code
* Explicit the IsKeyDesired TProps never behavior
* Add all trasformer objects to bot.transformers.$inferredTypes
* api-docs: Community Invites
Add support for invites that gives roles to users.
Add support for target users on invites.
Sort-of unrleated change required: `restManager.makeRequest` `resolve` function had to changed or else the `getTargetUsers` would hang forever due to a JSON parsing issue.
* fix type error & add bot helpers
* fix(rest)!: Remove calculateBits from changeToDiscordFormat
The rest manager currently has to assume that request bodies that have "permissions", "allow", "deny", "defaultMemberPermissions" fields are always meant as a permissions.
If these are not, for user error or future discord changes, this will break.
Also Discord expects these as strings, and discordeno does not abstract too much from the discord api, so it doesn't really makes sense for us to accept PermissionStrings[], the user should call calculateBits themselves, there is an argument to be made about accepting bigints since these are bitfields but that's another discussion.
* Channel.permissionOverwrites use PermissionStrings
For the transformed type we can keep the fact that it uses PermissionStrings
* Fix e2e test
* remove comment
I prefer semicolors, they also help avoiding certain pitfalls in JavaScript/TypeScript, such as the following code sample:
```js
const xyz = "test"
(something.else as string) = "another"
```
This results in a TypeError: "test" is not a function, this is because js thinks we are trying to call the string "test" as a function.
To fix this it requires a `;` somewhere before the `(`, such as `;(something ... ` which in my opinion is ugly and less clean overall.
* feat: enhance user tag getter
* feat(user): add `0000` condition and better jsdoc for tag
* chore(user): use this keyword instead of destructuring assignment
* fix(user): correct isLegacy logic
* feat(images): add ImageOptions
* refactor(images)!: split avatarUrl into more specific functions and add displayAvatarUrl
* feat(user)!: add more useful getters for user
* fix: update tests for images
* chore: using n suffix for bigint instead of converting to bigint
Co-authored-by: Fleny <Fleny113@outlook.com>
* fix: update dependencies for avatarUrl
Co-authored-by: Fleny <Fleny113@outlook.com>
* fix(user): correct the avatarUrl second parameter to avatar hash
Co-authored-by: Fleny <Fleny113@outlook.com>
* chore: undo unnecessary // from auto comment hotkey
Co-authored-by: Fleny <Fleny113@outlook.com>
---------
Co-authored-by: Fleny <Fleny113@outlook.com>
* feat: enhance user tag getter
* feat(user): add `0000` condition and better jsdoc for tag
* chore(user): use this keyword instead of destructuring assignment
* fix(user): correct isLegacy logic
* feat(components): File upload component for modals
* Update comments
upstream has been merged into the file uploads pr
* reverse transform, comment typo fix
Updated desiredProperties in transformers to be generic so that it can be used to retrive the bot desired properties, and removed the option from `CreateBotOptions.transformers.desiredProperties` as that would cause the typings for the bot to be incorrect
Co-authored-by: Awesome Stickz <awesome@stickz.dev>
* api-docs!: Modal Selects
* Fix transformer to handle the new response types
* Remove `Component` for consistency
Other interaction response types do not have `Component` in their names, so neither should the TextDisplay and Label interaction response types.
* Fix type errors in component transformers
---------
Co-authored-by: Awesome Stickz <awesome@stickz.dev>
* feat(types,bot): Add Label component and new modal stuff
Since now there are some fields that are only in responses the types got a bit more complicated
* Add char limits to label label & desc
* update comments
* fix format
* Move Require to shared.ts
* code review
---------
Co-authored-by: Awesome Stickz <awesome@stickz.dev>
forwardToBot has been removed in favor of directly using the events.message.
the default implementation for forwardToBot used to camelize the packet, however in most cases you want to preserve the snake_case, and for those that need camelCase it can be easly done in the message event function.
This also removes the gateway.preferSnakeCase option as it no longer has a use
The typedoc config is now only in the top-level config file instead of also being one per package
and all internal APIs are now marked as private so typedoc won't generate documentation for them, however we still need to export them to avoid typedoc warnings
The new internal APIs that are exported, since are marked as `@private` can have breaking changes without notices
* refactor(transformers)!: Use type helper to define customizers
This allows us to ensure that customizers always follow the correct types for the transformers and we don't have 2 places to add the types.
* remove outdated comment in transformInteractionDataResolved
* remove not needed cast
* remove not needed cast
Currently we import from `index.js` files where we could simply import the actual file(s) or module we need.
This also creates a bit of confusion since it isn't obvious from where stuff is coming from, especially when we are importing types such as `Discord<XYZ>` types both from `@discordeno/types` and a `index.js` in the same file, one such example is `transformers/reverse/component.ts`.
As far as I can tell, this does not have any specific advantage beside readability, maybe something with tree-shaking. (and for us, tree-shaking doesn't really matter)
The only files that still import index.js files are:
- index.js files themself
- bot/src/handlers.js since it does a `import * as handlers from './handlers/index.js'` and the alternative is like 90 lines of imports
Co-authored-by: Link <link20050703@gmail.com>