Giter Club home page Giter Club logo

discord-webhook-bundle's Introduction

Discord Webhook Bundle

Latest Stable Version Total Downloads License

Symfony Bundle for labymod/discord-webhook. Configure webhooks easily within your Symfony application

Versions & Compatibility

Release Supported PHP Versions Supported Symfony Versions Release Date Maintained Branch
1.x ^8.0 ^4.4, ^5.0, ^6.0 24.01.2022 Yes master

Installation

Composer installation

composer require labymod/discord-webhook-bundle

Symfony configuration & usage

  1. Enable your bundle in config/bundles.php:
    return [
        // ...
        \DiscordWebhookBundle\DiscordWebhookBundle::class => ['all' => true],
    ]
  2. Add a global and/or environment-based configuration file: config/[env]/discord_webhook.yaml

Configuration reference

# Default configuration
discord_webhook:
    default_url:          ~ # required, The Webhook URL for the default service.
    clients:
        # Prototype
        name: # choose a name (service-id) for your preconfigured client
            webhook_url:          ~ # required, The Discord Webhook URL for this client.
            username:             null # optional, The username for the Discord bot.
            avatar_url:           null # optional, URL which is used for the Bot avatar.

Usage

Default Client

With discord_webhook.default_url configured, the basic service (DiscordWebhookBundle\DiscordWebhook) is configured and publicly available in the service container:

Additional named clients

If you have configured one or more named clients like below, you can access them in two ways by their name.

discord_webhook
    # ...
    clients:
        announcements.client:
            webhook_url: 'https://discord.com/my/webhook/url'

Now this client is available as service too:

use DiscordWebhookBundle\DiscordWebhook;

class MyController
{
   public function myAction(DiscordWebhook $announcementsClient) // <-- Thanks to an ArgumentValueResolver, name the parameter after your client, and it will be resolved automatically
   {
      // OR, resolve it from the container:
      $webhook = $this->container->get('announcements.client');
   }
}

Documentation

For detailed documentation how to use the Webhooks, please refer to the underlying library:
https://github.com/LabyMod/discord-webhook/blob/master/README.md

For further documentation have a look here:

discord-webhook-bundle's People

Contributors

scrummer avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

fultuk

discord-webhook-bundle's Issues

Feature: Username/Avatar for default client

Add the possibility to set the username and/or avatar (optional) for the default webhook client:

discord_webhook:
    webhook_url: 'https://discord.com/my/webhook'
    username: 'Super Bot'
    avatar_url: 'https://url.to/my/cool/avatar'
    # ...

Reset Object state after sending invoking webhook (bug?)

Current state

As the various clients are being saved as service within the symfony container it becomes absolutely necessary that the services are being reset after the webhook was invoked.
If not, it can cause issues like contents being sent several times when invoking the same client with other content from an other part of the code.

Desired solution

After DiscordWebook::send() was invoked, all the properties (exclusive the ones configured via Symfony configuration) must be reset to the initial state (e.g. clear message, file(s) and remove all embeds from embeds-collection).

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.