Closed Mimickal closed 2 years ago
I dont think its good idea, the purpose of slash command builder is provide a easier way to build a valid metadata necessary to register the command at Discord servers
You can extend the class yourself and export it in your library if you want to achieve that, however this module was built strictly for validating and generating raw API data for application commands and what not, so I'm not a fan of adding this into the library.
Fair enough. I went ahead and wrote something that does this myself. For anybody else looking for functionality like this, I've uploaded it here https://github.com/Mimickal/discordjs-command-registry
Is your feature request related to a problem? Please describe. I am writing a little helper library that allows builders from this library to double as the structure for a command execution framework. It would be helpful if
SlashCommandBuilder
andSlashCommandSubcommandBuilder
had something like asetHandler(function)
method to associate a command execution handler function with a command. Is this something the team considers within the scope of this library?Describe the ideal solution I would like to bundle a handler function in with a
SlashCommandBuilder
andSlashCommandSubcommandBuilder
. Something like:Describe alternatives you've considered I am currently injecting this function directly into the builder prototypes. I do this instead of extending the classes so I can avoid needing to reimplement the
addSubcommand
function to changenew SlashCommandSubcommandBuilder()
to my subclass. This works, but it feels like a janky hack.Additional context This data would be to help library builders. It shouldn't modify the
toJSON()
data of any of the classes.