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

v4: ComponentHandler should allow type-constructing handlers #402

Open
diamondburned opened this issue Aug 4, 2023 · 0 comments
Open

v4: ComponentHandler should allow type-constructing handlers #402

diamondburned opened this issue Aug 4, 2023 · 0 comments

Comments

@diamondburned
Copy link
Owner

Currently, ComponentHandlers accept a ComponentData interface, and assertions must be done by the user. The user can make a mistake where an incorrect ID is used, causing a handler that expects one type to get an interaction of another type.

API proposal:

// Usage:
h.AddComponent("id", func(ctx context.Context, data ComponentData[*discord.ButtonInteraction]) {})

// Decls:
type ComponentData[T discord.ComponentInteraction] {...}
type ComponentHandler[T discord.ComponentInteraction] {...}
func (r *Router) AddComponent[T discord.ComponentInteraction](...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant