Managed application commands#454
Conversation
jchristgit
left a comment
There was a problem hiding this comment.
Thank you for the PR, and sorry for the late review!
This looks mostly good. It suffers from one problem: when an event is received, it's passed to a random consumer, due to the way we're using GenStage at the moment.
I think a better solution than to create an internal consumer would be to simply instruct users to call handle_event or maybe just a function handle_interaction that is called directly with the received interaction.
|
Hi @portasynthinca3! On master we removed GenStage in favour of What do you think? |
|
Hi! Sorry for not replying earlier. I have a couple of design decisions that i need but cannot make:
So, what do you think? |
Hmm this is a good point. Having it separately is also how I do it in my command library and it works well. I wouldn't mind accepting it into the main library giving that Discord's builtin slash commands have gotten relatively good, and should help remove much boilerplate when writing commands, but I do understand Nostrum is still relatively low-level so I agree that a separate library would be better.
I am a fan of reducing boilerplate, but in this case, as we currently have no way of limiting consumers to specific events, it means effectively duplicating all gateway events to the app's consumer and this one. If your bot is big enough this can cause considerable load increase, and I think we should strive to keep it relatively efficient. |
This pull request is intended to reduce boilerplate in projects that use application commands. Instead of requiring library users to implement a
Consumerand manually handleINTERACTION_CREATEevents, this pull requests enables them to define a separate module per command containing the command specification and its handling function.As a bonus, it removes magic numbers in command specs, instead opting in for atoms, and merges some spec fields into one field (for example,
nameandname_localizationsare represented as a tuple andvalue_minandvalue_maxas a range)