Skip to content

[FEATURE] Fluent msg/embed builder interface #12

@scrummer

Description

@scrummer
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes

Add a fluent interface to build messages/embeds. Similar to the symfony config-definition builder.

The benefit would be that you can better see how the messages would look like when they're being sent and it makes building complex embeds easier (and cooler) I guess.

Could look something like this:

$builder = new WebhookBuilder();
$builder
    ->embeds()
        ->embed()
            ->title('embed ONE title')
            ->timestamp(new \DateTime())
            ->fields()
                ->field()
                    ->name('field title')
                    ->value('some field value')
                ->end()
            ->end()
        ->end()
        ->embed()
            ->title('embed TWO title')
            ->author()
                ->name('scrummer')
                ->iconUrl('https://my.icon.url/icon.jpg')
            ->end()
        -> end()
    ->end()
;

$builder->send();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions