hikari-py/hikari

Specialize InteractionCreateEvent

Opened this issue · 4 comments

davfsa commented

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.

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

ModalInteractionCreateEvent
ComponentInteractionCreateEvent
CommandInteractionCreateEvent
AutocompleteInteractionCreateEvent

is the way to go

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

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