GithubHelp home page GithubHelp logo

labymod / discord-webhook Goto Github PK

View Code? Open in Web Editor NEW
12.0 12.0 5.0 179 KB

A lightweight library for Discord™ Webhooks

Home Page: https://packagist.org/packages/labymod/discord-webhook

License: MIT License

PHP 99.46% Shell 0.54%
discord php webhook

discord-webhook's People

Contributors

scrummer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

discord-webhook's Issues

Embed implementation

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

Goal

Configure & send messages with embeds to a given discord channel

Workflow

Unlike the old library (Webhooks) we want to design the interface to create embeds less painful.

An option would be to create a universal embed class and configure the type with constants.

Feature: Simple Webhooks

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

Description

Currently it is quite an overhead to create simple webhooks. Even the simplest ones require at least this boilerplate:

$webhook = new Webhook('your very long webhook url here');
$webhook->setMessage('My cool message');
$webhook->send();

The idea

New class: SimpleWebhook
You are able to set the default url in two ways:

  • Via env variable: DWH_DEFAULT_URL=https://xy
  • Via static property: SimpleWebhook::setDefaultUrl('xy');

Then, in your application it is as simple as this to send basic webhooks with text-messages:

\DiscordWebhook\SimpleWebhook::sendMessage('my message');

Todo

  • New SimpleWebhook class with static API
  • environment resolver
  • Priority logic for WH endpoint

Project: Symfony Bundle

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

Description

Create a symfony bundle with or within this library.
Goals are:

  • Configure channels in yaml directly
  • Resolve the webhook from DI
  • Make endpoint configuration simpler

Todo

[FEATURE] Fluent msg/embed builder interface

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();

Make WH constructor accept a single string too

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

Make the constructor accept a string OR an array of webhook URLs.
Currently you have to pack also a single URL into an array even if you do not intend to use more than one URL.

// OLD:
new \DiscordWebhook\Webhook(['https://discord.com/webhook/url']);

// NEW, these two options:
new \DiscordWebhook\Webhook(['https://discord.com/webhook/url']);
new \DiscordWebhook\Webhook('https://discord.com/webhook/url');

// ofc. if you want more WHs just add them to the array:
new \DiscordWebhook\Webhook([
    'https://discord.com/webhook/url/one',
    'https://discord.com/webhook/url/two',
    'https://discord.com/webhook/url/three'
]);

Make ready for a symfony-bundle-integration

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

Goal is to create a external repo for a Symfony bundle to easily integrate discord webhooks into any symfony application.

PHP 8.1 compatibility

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
  • Update repo to use ddev.
  • #6
  • General 8.1 compatibility
  • Improve README with version compatibility
  • Drop support for PHP 7.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.