hikari icon indicating copy to clipboard operation
hikari copied to clipboard

Allow a single builder with `components=`

Open ashleney opened this issue 3 years ago • 0 comments

Summary

Allow users to pass a custom class that is built into a list of action row payloads. This should help with abstracting some custom component handlers.

Why is this needed?

There have been a few new component handlers recently. Generally, users are forced to use components as follows:

handler = library.SomeHandler(...)
await channel.send(components=handler.build())

It'd be ideal if the .build() could be abstracted away with:

handler = library.SomeHandler(...)
await channel.send(components=handler)

Ideal implementations

new builder protocol/abc

components will allow Sequence[ComponentBuilder] | CoolComponentHandlerNameIsWIP

await channel.send(components=handler)

allow pre-existing ComponentBuilder to return lists

If ComponentBuilder returns a sequence it will be assumed to be a list of action row payloads.

await channel.send(component=handler)

Checklist

  • [X] 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.

ashleney avatar Jan 24 '22 13:01 ashleney