PHPackages                             arthurpar06/laravel-discord-notifier - 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. arthurpar06/laravel-discord-notifier

ActiveLibrary

arthurpar06/laravel-discord-notifier
====================================

A strongly-typed way to send Discord notifications through Laravel's notification system, via webhooks or a bot.

v0.2.0(1mo ago)0822[1 PRs](https://github.com/arthurpar06/laravel-discord-notifier/pulls)MITPHPPHP ^8.3CI passing

Since Jul 14Pushed 1mo agoCompare

[ Source](https://github.com/arthurpar06/laravel-discord-notifier)[ Packagist](https://packagist.org/packages/arthurpar06/laravel-discord-notifier)[ Docs](https://github.com/arthurpar06/laravel-discord-notifier)[ RSS](/packages/arthurpar06-laravel-discord-notifier/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (14)Versions (3)Used By (0)

Laravel Discord Notifier
========================

[](#laravel-discord-notifier)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b3edf9d0bda9301f2756c7a30db02516bec9270d1b0cbaa46c31305cec1f4fe8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61727468757270617230362f6c61726176656c2d646973636f72642d6e6f7469666965722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/arthurpar06/laravel-discord-notifier)[![Total Downloads](https://camo.githubusercontent.com/97b08571159dc8021a22de2ed9b8a49bdd6f9cdf6c00db1118dbb73b0526ec60/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61727468757270617230362f6c61726176656c2d646973636f72642d6e6f7469666965722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/arthurpar06/laravel-discord-notifier)

A strongly-typed way to send Discord messages through Laravel's notification system — over a **webhook** or a **bot** — without ever hand-writing the Discord API payload again.

```
use Arthurpar06\DiscordNotifier\Messages\DiscordMessage;
use Arthurpar06\DiscordNotifier\Embeds\DiscordEmbed;
use Arthurpar06\DiscordNotifier\Enums\DiscordColor;

DiscordMessage::make()
    ->content('Deployment finished')
    ->embed(
        DiscordEmbed::make()
            ->title('Bonjour')
            ->description('Everything is green.')
            ->color(DiscordColor::Green)
            ->field('Environment', 'production', inline: true)
    );
```

Your IDE and the type system remember the field names, the enums, and the limits — so you don't have to reopen the Discord docs every time.

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

[](#installation)

```
composer require arthurpar06/laravel-discord-notifier
```

Publish the config file:

```
php artisan vendor:publish --tag="discord-notifier-config"
```

To deliver via a bot, set your bot token in `.env`:

```
DISCORD_BOT_TOKEN=your-bot-token
```

```
// config/discord-notifier.php
return [
    'bot' => [
        'token' => env('DISCORD_BOT_TOKEN'),
        'api_base' => 'https://discord.com/api/v10',
    ],
];
```

There is **no default route** — every notification declares where it goes.

Building a message
------------------

[](#building-a-message)

`DiscordMessage` models the [Create Message](https://docs.discord.com/developers/resources/message#create-message) body. Everything is fluent and typed:

```
use Arthurpar06\DiscordNotifier\Messages\DiscordMessage;
use Arthurpar06\DiscordNotifier\Messages\AllowedMentions;
use Arthurpar06\DiscordNotifier\Embeds\DiscordEmbed;
use Arthurpar06\DiscordNotifier\Enums\AllowedMentionType;
use Arthurpar06\DiscordNotifier\Enums\MessageFlag;

DiscordMessage::make()
    ->content('Heads up ')
    ->embeds([
        DiscordEmbed::make()
            ->title('Report')
            ->footer('generated automatically')
            ->author('CI bot'),
    ])
    ->allowedMentions(AllowedMentions::make()->parse([AllowedMentionType::Users]))
    ->flags(MessageFlag::SuppressNotifications);
```

Only the fields you set are sent. Discord's limits (≤10 embeds, content ≤2000 chars, embed field caps, the `IS_COMPONENTS_V2` mutual-exclusivity rule, …) are validated when the message is serialized, with an exception that names the offending field.

Buttons
-------

[](#buttons)

Attach buttons with `->button()` (a single button in its own row) or `->actionRow()` (up to five buttons per row, up to five rows per message). Buttons are built through a named constructor per style, so you can't assemble an invalid combination:

```
use Arthurpar06\DiscordNotifier\Components\Button;
use Arthurpar06\DiscordNotifier\Embeds\DiscordEmbed;
use Arthurpar06\DiscordNotifier\Messages\DiscordMessage;

DiscordMessage::make()
    ->embed(DiscordEmbed::make()->title('Deploy finished'))
    ->actionRow(
        Button::link('https://ci.example.com/builds/42', 'View build'),
        Button::primary('redeploy', 'Redeploy'),
    );
```

ConstructorStyleNeeds`Button::link($url, $label = null)`Linka URL`Button::primary/secondary/success/danger($customId, $label)`interactivea `custom_id``Button::premium($skuId)`Premiuman SKU idAll non-premium buttons also support `->disabled()` and `->emoji('🔥')` (or a custom emoji array).

> **Interactive buttons need your own interaction handling.** This package only *sends* messages. `link` and `premium` buttons work with nothing extra, but `primary`/`secondary`/`success`/`danger` buttons raise a Discord Interaction when clicked — if your application does not answer it (via a gateway or an HTTP interactions endpoint) within three seconds, Discord shows "This interaction failed." Reach for link buttons unless you already run an interaction handler.

Sending notifications
---------------------

[](#sending-notifications)

In your notification, list `discord` in `via()` and return a `DiscordMessage` from `toDiscord()`:

```
use Arthurpar06\DiscordNotifier\Messages\DiscordMessage;
use Illuminate\Notifications\Notification;

class DeploymentFinished extends Notification
{
    public function via($notifiable): array
    {
        return ['discord'];
    }

    public function toDiscord($notifiable): DiscordMessage
    {
        return DiscordMessage::make()->content('Deployment finished ✅');
    }
}
```

### Route on demand

[](#route-on-demand)

Pass a bot **channel id** (a guild channel or a user's DM channel) or an explicit route:

```
use Illuminate\Support\Facades\Notification;
use Arthurpar06\DiscordNotifier\Routing\DiscordRoute;

// bare channel id → delivered by the bot
Notification::route('discord', config('services.discord.admin_channel_id'))
    ->notify(new DeploymentFinished);

// explicit webhook
Notification::route('discord', DiscordRoute::webhook(config('services.discord.webhook')))
    ->notify(new DeploymentFinished);
```

### Route from a model

[](#route-from-a-model)

Give the notifiable a `routeNotificationForDiscord()` returning its own channel id — e.g. a stored private DM channel:

```
class User extends Authenticatable
{
    use Notifiable;

    public function routeNotificationForDiscord(): ?string
    {
        return $this->discord_private_channel_id ?: null;
    }
}

$user->notify(new DeploymentFinished);
```

Returning `null` is safe: a notifiable with no route is skipped, so `discord` can sit in a `via()` list alongside other channels even when only some of your users have linked their account.

```
public function via($notifiable): array
{
    return ['mail', 'discord']; // users without Discord just get the mail
}
```

How routing is resolved
-----------------------

[](#how-routing-is-resolved)

The route value is resolved to a transport, unambiguously:

Route valueTransport`DiscordRoute::webhook($url)` / `DiscordRoute::channel($id)`as declareda string starting with `http`webhooka numeric snowflake stringbot channel (`POST /channels/{id}/messages`)A DM to a user and a message to a guild channel are the same bot call — store the channel id and send.

### When there is no route

[](#when-there-is-no-route)

SituationResulta notifiable returns `null`, `''` or `[]`**skipped** — no message, no exception`Notification::route('discord', '')`**throws** — you asked for delivery but gave no destinationany route that is neither a URL nor a snowflake (e.g. `'not-a-url'`)**throws** — a present-but-invalid route is a misconfigurationAn absent route and a malformed one are different things. A model with nothing stored is ordinary and stays quiet; a value that was meant to be a destination and isn't fails loudly.

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

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

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance91

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.9% 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

Every ~0 days

Total

2

Last Release

47d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/41431456?v=4)[Arthur Parienté](/maintainers/arthurpar06)[@arthurpar06](https://github.com/arthurpar06)

---

Top Contributors

[![arthurpar06](https://avatars.githubusercontent.com/u/41431456?v=4)](https://github.com/arthurpar06 "arthurpar06 (47 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

laravelnotificationswebhookdiscordarthurpar06discord-notifier

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/arthurpar06-laravel-discord-notifier/health.svg)

```
[![Health](https://phpackages.com/badges/arthurpar06-laravel-discord-notifier/health.svg)](https://phpackages.com/packages/arthurpar06-laravel-discord-notifier)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.2k14.2M148](/packages/dedoc-scramble)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k6.1M53](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

331634.0k37](/packages/codewithdennis-filament-select-tree)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

24795.1k](/packages/harris21-laravel-fuse)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

25263.1k](/packages/vormkracht10-laravel-mails)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3915.5k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

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