Skip to content
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

Specialize InteractionCreateEvent #1777

Open
1 task done
davfsa opened this issue Dec 7, 2023 · 4 comments · May be fixed by #2023
Open
1 task done

Specialize InteractionCreateEvent #1777

davfsa opened this issue Dec 7, 2023 · 4 comments · May be fixed by #2023
Labels
enhancement New feature or request

Comments

@davfsa
Copy link
Member

davfsa commented Dec 7, 2023

Summary

Specialize InteractionCreateEvent into the different interaction types, similar how MessageCreateEvent is specialized for guilds and dms

Why is this needed?

Nicer DX

Ideal implementation

Provide more concrete subclasses with correct typing for interaction.

Checklist

  • I have searched the issue tracker and have made sure it's not a duplicate. If it is a follow up of another issue, I have specified it.
@davfsa davfsa added the enhancement New feature or request label Dec 7, 2023
@syncblaze
Copy link
Contributor

syncblaze commented Aug 18, 2024

I just stumbled across this issue and i would like to implement it.

Taking a first look at this, the InteractionCreateEvent should have 3 subclasses:
ModalInteractionCreateEvent
ComponentInteractionCreateEvent
(Base)CommandInteractionCreateEvent

Or would you split (Base)CommandInteractionCreateEvent into:
CommandInteractionCreateEvent and AutocompleteInteractionCreateEvent?

I hope its understandable what i mean basically its just if there should be a Event subclass for only BaseCommandInteraction or if there should be event subclasses for the 2 subclasses of BaseCommandInteraction.

Ig it is more understandable if you take a look at hikari.interaction

@syncblaze
Copy link
Contributor

ModalInteractionCreateEvent
ComponentInteractionCreateEvent
CommandInteractionCreateEvent
AutocompleteInteractionCreateEvent

is the way to go

@syncblaze syncblaze linked a pull request Aug 18, 2024 that will close this issue
2 tasks
@FasterSpeeding
Copy link
Collaborator

Provide more concrete subclasses with correct typing for interaction.

btw if events should be subclasses to have "correct typing" like this then shouldn't this be applied to stuff like channel events as well

@syncblaze
Copy link
Contributor

syncblaze commented Aug 18, 2024

btw if events should be subclasses to have "correct typing" like this then shouldn't this be applied to stuff like channel events as well

For these Interaction events it makes more sense because 90% of the people using InteractionCreate use it for handling components since Command interactions are often handled by your command handler lib.

And then it would be way nicer to have dedicated events because you dont have to make extra checks and you have better typing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants