ghostbear / kumaslash

A discord bot made like a Enterprise application
Mozilla Public License 2.0
10 stars 3 forks source link

Rework Event Handler Components #33

Closed ghostbear closed 1 year ago

ghostbear commented 1 year ago

The current way of handling events with the event handler is far from perfect.

The idea is to create a more Spring type of working with Discord4J would be to create a few annotations that would allow us to define event handlers.

@EventHandlerComponent
public class MyEventHandler {

  @SlashCommandHandler(command = "parent.subcommand")
  public Mono<Void> mySubcommandHandler(ChatInputInteractionEvent event) {}

  @EventHandler(for = ModalSubmitInteractionEvent.class, customId = "myCustomId")
  public Mono<Void> myModalHandler(ModalSubmitInteractionEvent event) {}

  @EventHandler(for = ModalSubmitInteractionEvent.class)
  public Publisher<?> myMessageCreateHandler(MessageCreateEvent event)

}

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/config/BeanPostProcessor.html