PHPackages                             nicolaskion/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. nicolaskion/discord-notification-channel

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

nicolaskion/discord-notification-channel
========================================

Laravel notification driver for Discord.

v0.1(1y ago)021MITPHPPHP ^7.2|^8.0

Since Mar 21Pushed 1y agoCompare

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

READMEChangelog (1)Dependencies (9)Versions (2)Used By (0)

Discord notification channel for Laravel 6.0+
=============================================

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

This package makes it easy to send notifications using the [Discord bot API](https://discord.com/developers/docs/intro) with Laravel.

Contents
--------

[](#contents)

- [Discord notification channel for Laravel 6.0+](#discord-notification-channel-for-laravel-56)
    - [Contents](#contents)
    - [Installation](#installation)
        - [Setting up your Discord bot](#setting-up-your-discord-bot)
    - [Usage](#usage)
        - [Available Message methods](#available-message-methods)
    - [Changelog](#changelog)
    - [Testing](#testing)
    - [Security](#security)
    - [Contributing](#contributing)
    - [Credits](#credits)
    - [License](#license)

Installation
------------

[](#installation)

You can install the package via composer:

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

Next, you must load the service provider:

```
// config/app.php
'providers' => [
    // ...
    NotificationChannels\Discord\DiscordServiceProvider::class,
],
```

### Setting up your Discord bot

[](#setting-up-your-discord-bot)

1. [Create a Discord application.](https://discord.com/developers/applications)
2. Click the `Create a Bot User` button on your Discord application.
3. Paste your bot's API token, found under `App Bot User`, in your `services.php` config file:

    ```
    // config/services.php
    'discord' => [
        'token' => 'YOUR_API_TOKEN',
    ],
    ```
4. Add the bot to your server and identify it by running the artisan command:

    ```
    php artisan discord:setup
    ```

Usage
-----

[](#usage)

In every model you wish to be notifiable via Discord, you must add a channel ID property to that model accessible through a `routeNotificationForDiscord` method:

```
class Guild extends Eloquent
{
    use Notifiable;

    public function routeNotificationForDiscord()
    {
        return $this->discord_channel;
    }
}
```

> **NOTE**: Discord handles direct messages as though they are a regular channel. If you wish to allow users to receive direct messages from your bot, you will need to create a private channel with that user.
>
> An example workflow may look like the following:
>
> 1. Your `users` table has two discord columns: `discord_user_id` and `discord_private_channel_id`
> 2. When a user updates their Discord user ID (`discord_user_id`), generate and save a private channel ID (`discord_private_channel_id`)
> 3. Return the user's `discord_private_channel_id` in the `routeNotificationForDiscord` method on the `User` model
>
> You can generate direct message channels by using the `getPrivateChannel` method in the `NotificationChannels\Discord\Discord` class
>
> ```
> use NotificationChannels\Discord\Discord;
>
> class UserDiscordSettingsController
> {
>     public function store(Request $request)
>     {
>         $userId = $request->input('discord_user_id');
>         $channelId = app(Discord::class)->getPrivateChannel($userId);
>
>         Auth::user()->update([
>             'discord_user_id' => $userId,
>             'discord_private_channel_id' => $channelId,
>         ]);
>     }
> }
> ```
>
>
>
> Please take note that the `getPrivateChannel` method only accepts [Discord's snowflake IDs](https://discord.com/developers/docs/reference#snowflakes). There is no API route provided by Discord to lookup a user's ID by their name and tag, and the process for copying and pasting a user ID can be confusing to some users. Because of this, it is recommended to add the option for users to connect their Discord account to their account within your application either by logging in with Discord or linking it to their pre-existing account.

You may now tell Laravel to send notifications to Discord channels in the `via` method:

```
// ...
use NotificationChannels\Discord\DiscordChannel;
use NotificationChannels\Discord\DiscordMessage;

class GameChallengeNotification extends Notification
{
    public $challenger;

    public $game;

    public function __construct(Guild $challenger, Game $game)
    {
        $this->challenger = $challenger;
        $this->game = $game;
    }

    public function via($notifiable)
    {
        return [DiscordChannel::class];
    }

    public function toDiscord($notifiable)
    {
        return DiscordMessage::create("You have been challenged to a game of *{$this->game->name}* by **{$this->challenger->name}**!");
    }
}
```

### Available Message methods

[](#available-message-methods)

- `body(string)`: Set the content of the message. ([Supports basic markdown](https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline-))
- `embed(array)`: Set the embedded content. ([View embed structure](https://discord.com/developers/docs/resources/channel#embed-object))
- `components(array)`: Set the component content. ([View component structure](https://discord.com/developers/docs/interactions/message-components#component-object))

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Cody Scott](https://github.com/codyphobe)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance46

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 51.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

417d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/deb291b3b33848fe9c86db646dc21058c4d8a20c9db83e618954af7abe4e68a2?d=identicon)[NicolasKion](/maintainers/NicolasKion)

---

Top Contributors

[![codyphobe](https://avatars.githubusercontent.com/u/207072?v=4)](https://github.com/codyphobe "codyphobe (54 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (10 commits)")[![BennySama](https://avatars.githubusercontent.com/u/24943944?v=4)](https://github.com/BennySama "BennySama (8 commits)")[![owenvoke](https://avatars.githubusercontent.com/u/1899334?v=4)](https://github.com/owenvoke "owenvoke (4 commits)")[![NicolasKion](https://avatars.githubusercontent.com/u/172045106?v=4)](https://github.com/NicolasKion "NicolasKion (3 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (3 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (2 commits)")[![kawax](https://avatars.githubusercontent.com/u/1502086?v=4)](https://github.com/kawax "kawax (2 commits)")[![messerli90](https://avatars.githubusercontent.com/u/3306651?v=4)](https://github.com/messerli90 "messerli90 (2 commits)")[![nullx27](https://avatars.githubusercontent.com/u/73673?v=4)](https://github.com/nullx27 "nullx27 (2 commits)")[![dmyers](https://avatars.githubusercontent.com/u/207171?v=4)](https://github.com/dmyers "dmyers (1 commits)")[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (1 commits)")[![m1guelpf](https://avatars.githubusercontent.com/u/23558090?v=4)](https://github.com/m1guelpf "m1guelpf (1 commits)")[![maartenvw](https://avatars.githubusercontent.com/u/9413341?v=4)](https://github.com/maartenvw "maartenvw (1 commits)")[![romulosalmeida](https://avatars.githubusercontent.com/u/37348255?v=4)](https://github.com/romulosalmeida "romulosalmeida (1 commits)")[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (1 commits)")[![deto1986](https://avatars.githubusercontent.com/u/3199863?v=4)](https://github.com/deto1986 "deto1986 (1 commits)")[![xHeinrich](https://avatars.githubusercontent.com/u/7674587?v=4)](https://github.com/xHeinrich "xHeinrich (1 commits)")[![corsair](https://avatars.githubusercontent.com/u/1847891?v=4)](https://github.com/corsair "corsair (1 commits)")

---

Tags

laravelnotificationdriverdiscordchannel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nicolaskion-discord-notification-channel/health.svg)

```
[![Health](https://phpackages.com/badges/nicolaskion-discord-notification-channel/health.svg)](https://phpackages.com/packages/nicolaskion-discord-notification-channel)
```

###  Alternatives

[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)[snoeren-development/laravel-discord-webhook-channel

Send notifications to a Discord webhook.

1549.8k1](/packages/snoeren-development-laravel-discord-webhook-channel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
