PHPackages                             awssat/discord-notification-channel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. awssat/discord-notification-channel

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

awssat/discord-notification-channel
===================================

Discord Notification Channel for laravel.

1.4.5(1y ago)94122.8k↓34.6%7[1 PRs](https://github.com/awssat/discord-notification-channel/pulls)MITPHPPHP ^7.1.3|^8.0CI failing

Since Jan 31Pushed 1y ago2 watchersCompare

[ Source](https://github.com/awssat/discord-notification-channel)[ Packagist](https://packagist.org/packages/awssat/discord-notification-channel)[ RSS](/packages/awssat-discord-notification-channel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (11)Used By (0)

Laravel Discord Notification Channel
====================================

[](#laravel-discord-notification-channel)

### Introduction

[](#introduction)

Send Discord messages through webhook with Discord or Slack payload via Laravel Notifications channels

Features
--------

[](#features)

- Support slack payload by using `new  (new SlackMessage)` or `$this->toSlack($notifiable)`
- Support discord webhook payload
- Easy to use

Install
-------

[](#install)

Via Composer

```
composer require awssat/discord-notification-channel
```

Usage
-----

[](#usage)

in your notification you should define the `discord` channel in the via method

```
public function via($notifiable)
{
    return ['mail', 'discord'];
}
```

you should have a `toDiscord` method

```
    public function toDiscord($notifiable)
    {
        return (new DiscordMessage)
            ->from('Laravel')
            ->content('Content')
            ->embed(function ($embed) {
                $embed->title('Discord is cool')->description('Slack nah')
                    ->field('Laravel', '9.0.0', true)
                    ->field('PHP', '8.0.0', true);
            });
    }
```

`toDiscord` method can receive `DiscordMessage` or `SlackMessage`

#### Example of slack message

[](#example-of-slack-message)

```
    public function toDiscord($notifiable)
    {
        return (new SlackMessage)
                ->content('One of your invoices has been paid!');
    }
```

or if you want you can make it run from `toSlack` method

```
    public function toSlack($notifiable)
    {
        return (new SlackMessage)
                ->content('One of your invoices has been paid!');
    }

    public function toDiscord($notifiable)
    {
        return $this->toSlack($notifiable);
    }
```

 for further laravel slack messages examples

### Routing Discord Notifications

[](#routing-discord-notifications)

To route Discord notifications to the proper location, define a `routeNotificationForDiscord` method on your notifiable entity. This should return the webhook URL to which the notification should be delivered. read Webhook Discord docs here

```
