Converters

Hey wondering if, it is possible to have type convertions in sapphire or with any of it's utility packages, I have seen the Resolver class but i think there are some methods missing in example the library dpy has a series of converters one is the ColorConverter, so i was wondering whether it's possible to have such converters in sapphire https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/converter.py#L619
GitHub
discord.py/discord/ext/commands/converter.py at master · Rapptz/dis...
An API wrapper for Discord written in Python. Contribute to Rapptz/discord.py development by creating an account on GitHub.
Solution:
I think you're just looking for arguments https://www.sapphirejs.dev/docs/Guide/arguments/using-arguments But also do not forget that nothing stops you from simply defining a function in some utility file and export it then import it elsewhere. You're not restricted to what the framework provides, you can still use regular JavaScript concepts too. If you must have the function as part of the container though then we have this plugin: https://github.com/sapphiredev/plugins/tree/main/packages/utilities-store#readme Other than that, the actual conversion is something you're gonna have to write yourself. I don't think discordjs exports their color conversion functions, but we're not going to mirror their code (overhead, maintenance, etc) so if you want to use what discordjs used internally then create an issue on their repo asking for the functions to be moved to a subpackage (assuming it's not exported). ...
Sapphire Framework
Using arguments in your commands | Sapphire
This section is only for the message command and is not relevant for the other command types. If you are looking for how
GitHub
plugins/packages/utilities-store at main · sapphiredev/plugins
Plugins for the Sapphire Framework. Contribute to sapphiredev/plugins development by creating an account on GitHub.
Jump to solution
2 Replies
Solution
Favna
Favna9mo ago
I think you're just looking for arguments https://www.sapphirejs.dev/docs/Guide/arguments/using-arguments But also do not forget that nothing stops you from simply defining a function in some utility file and export it then import it elsewhere. You're not restricted to what the framework provides, you can still use regular JavaScript concepts too. If you must have the function as part of the container though then we have this plugin: https://github.com/sapphiredev/plugins/tree/main/packages/utilities-store#readme Other than that, the actual conversion is something you're gonna have to write yourself. I don't think discordjs exports their color conversion functions, but we're not going to mirror their code (overhead, maintenance, etc) so if you want to use what discordjs used internally then create an issue on their repo asking for the functions to be moved to a subpackage (assuming it's not exported). It's also a well known fact that Dpy does and offers very much for end-users but at least my opinion with that is that that also makes it very bloated (take for example that discordjs doesn't even offer a framework, that's where sapphire comes in). This bloatedness of Dpy also means there is very little custom ingenuity by its users and bots just end up being all samey which is bad for the ecosystem as a whole.
Sapphire Framework
Using arguments in your commands | Sapphire
This section is only for the message command and is not relevant for the other command types. If you are looking for how
GitHub
plugins/packages/utilities-store at main · sapphiredev/plugins
Plugins for the Sapphire Framework. Contribute to sapphiredev/plugins development by creating an account on GitHub.
Xeno™
Xeno™9mo ago
Yeah I see, Thanks 👍