-
Notifications
You must be signed in to change notification settings - Fork 130
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
Managed application commands #454
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Consumer
and manually handleINTERACTION_CREATE
events, 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,
name
andname_localizations
are represented as a tuple andvalue_min
andvalue_max
as a range)