Replies: 5 comments 23 replies
-
Do we want to give the user the option to constantly or once for each warn code? Could pop it in client options for example |
Beta Was this translation helpful? Give feedback.
-
Also tbch I'm not that much of a fan of nested functions, are there alternatives we can use? Like pushing warning codes to an array or something. I can benchmark if necessary |
Beta Was this translation helpful? Give feedback.
-
Should we have a list of deprecation codes and their corresponding descriptions (thus just passing the code in the deprecation call)? Or just have it typed out in each deprecation call? |
Beta Was this translation helpful? Give feedback.
-
About the deprecation names/codes whatever, we should probably use specific things to make it harder for codes to overlap in different prs and such For example: Support sending multiple embeds (#1239) would use either |
Beta Was this translation helpful? Give feedback.
-
Should we also add the warning emits to new prs? or should we just stop doing that and use only emitDeprecation for new things once its merged? |
Beta Was this translation helpful? Give feedback.
-
Already discussed a fair bit on Discord starting here. I can own development of this feature. Summarizing prior conversation:
It's probably a good idea to use
process.emitWarning
to emit deprecation warnings, because process warnings are automatically exposed to the user by default and can be controlled through Node CLI flags (including flags specifically for deprecation warnings). This is common in other libraries as well.To avoid breaking changes, we can also continue to emit deprecation warnings to the
Client
warn
event, though ironically there's no good way to mark this behavior as deprecated since thewarn
event is also used for Discord warnings, and we have no way to tell which warnings a user is relying on. However, because process warnings log to the console by default, it's likely that anyone who was relying on deprecation warnings coming from thewarn
event will notice the extra console output and realize they should update their handling, so it's probably fine to remove deprecation warnings from thewarn
event a few breaking changes after introducing process deprecation warnings.warn
event will probably involve using the--no-deprecation
CLI flag to suppress the default console output and/or handling theprocess
warning
event.Node.js docs say it's a best practice to avoid emitting duplicate warnings to avoid console spam if a deprecated code path is used multiple times. This requires the library to keep track of which deprecation warnings it has already emitted. Given this and the fact that we still need to emit deprecations to the client
warn
event for now, it probably makes sense to implement this as an internal helper. I've posted the way I handle this in my own library for reference.Beta Was this translation helpful? Give feedback.
All reactions