-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bot] Customize Typings Based on DesiredProperties #2983
Comments
Would love to hop in on this conversation since it's been a topic of conversation with us on Discord, mainly around I'm not opposed to a CLI, I think a CLI makes sense. It allows those who use TypeScript that type safety. I can say from experience that this threw me for a loop as well, mainly cause I didn't know Having proper documentation, typing, and/or CLI could've mitigated that surprise and frustration for me. On the CLI generation... JS FileSquashed the details to make this issue shorter
Pros
Cons
Discordeno ChangesWe would have to change this line to no longer pass in an empty object. We could, depending on the implementation of the config, just pass in the config. User Side import myConfig from './discordeno.config.js'
createBot({
config: myConfig
}) On the Discordeno side we could change it to: {
transformers: createTransformers(myConfig.transformers ?? {}),
} We would also have to change the default desiredProperties desiredProperties: {
attachment: {
id: false,
filename: false,
contentType: false,
size: false,
url: false,
proxyUrl: false,
height: false,
width: false,
ephemeral: false,
description: false,
},
// all the other properties here
// Then spread the options.desiredProperties
...options.desiredProperties
} Doing it this way would allow defaults and protect for future additions while also overwriting the object's properties as a last step. In this case, based on the example below, the entire Example ConfigUsing
export default {
transformers: {
desiredProperties: {
attachment: {
id: true,
filename: true,
contentType: true,
size: true,
url: true,
proxyUrl: true,
height: true,
width: true,
ephemeral: true,
description: true,
}
}
}
} JSONSquashed the details to make this issue shorter
Pros
Cons
Discordeno ChangesSame as the JS implementation as I previously documented. That's going to be more or less the same for both. User side would be similar, just adding the Example Config{
"$schema": "https://some.schema/discordeno-19.0.0.json",
"transformers": {
"desiredProperties": {
"attachment": {
"id": true,
"filename": "true"
}
}
}
} I won't list out all the items. My OpinionMy personal opinion is to go the JS route. CLI could look like: npx discordeno generate types We could also create a shortcut with Inside the CLI we could look for a |
This issue has gone stale for over a month. If this issue is useful, leave a comment below. Otherwise, it will be closed shortly. |
Bump for stale bot |
Is your feature request related to a problem? Please describe.
It would be better to have typings be generated automatically based on the desired properties the user provides.
Describe the solution you'd like
npx prisma generate
where we donpx discordeno generate
createTransformers<>()
which can provide custom onesDescribe alternatives you've considered
Additional context
With current solution it is not typesafe as a desiredPropety could be set to false and yet the typings say it exists. We could make all properties optional but that isn't exactly a good UX either.
The text was updated successfully, but these errors were encountered: