PHPackages                             maxlego08/laravel-discord-alerts - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. maxlego08/laravel-discord-alerts

ActiveLibrary[HTTP &amp; Networking](/categories/http)

maxlego08/laravel-discord-alerts
================================

Send a message to Discord

1.8(1y ago)05MITPHPPHP ^8.2

Since Mar 27Pushed 1y agoCompare

[ Source](https://github.com/Maxlego08/laravel-discord-alerts)[ Packagist](https://packagist.org/packages/maxlego08/laravel-discord-alerts)[ Docs](https://github.com/spatie/laravel-discord-alerts)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/maxlego08-laravel-discord-alerts/feed)WikiDiscussions main Synced 1mo ago

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

Quickly send a message to Discord
=================================

[](#quickly-send-a-message-to-discord)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ad398a0547fe3a3cba1eb32a347ca4a869dadcb04535d8f97e9949a632b11857/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d646973636f72642d616c657274732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-discord-alerts)[![run-tests](https://github.com/spatie/laravel-discord-alerts/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-discord-alerts/actions/workflows/run-tests.yml)[![PHPStan](https://github.com/spatie/laravel-discord-alerts/actions/workflows/phpstan.yml/badge.svg)](https://github.com/spatie/laravel-discord-alerts/actions/workflows/phpstan.yml)[![Check & fix styling](https://github.com/spatie/laravel-discord-alerts/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/spatie/laravel-discord-alerts/actions/workflows/php-cs-fixer.yml)[![Total Downloads](https://camo.githubusercontent.com/ced380ac4bda3b7e75cdbfbf6533d82d8928e3caee42761c798d7776e2b76d2d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d646973636f72642d616c657274732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-discord-alerts)

This package can quickly send alerts to Discord. You can use this to notify yourself of any noteworthy events happening in your app.

Want to quickly send alerts to Slack? Then check out [laravel-slack-alerts](https://github.com/spatie/laravel-slack-alerts).

```
use Spatie\DiscordAlerts\Facades\DiscordAlert;

DiscordAlert::message("You have a new subscriber to the {$newsletter->name} newsletter!");
```

Under the hood, a job is used to communicate with Discord. This prevents your app from failing in case Discord is down.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/d33cc0749f7465532d690eca930bba98defba59b8bd0510dab55fdae0f81ff17/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d646973636f72642d616c657274732e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-discord-alerts)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard ``wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-discord-alerts
```

You can set a `DISCORD_ALERT_WEBHOOK` env variable containing a valid Discord webhook URL. You can learn how to get a webhook URL [in the Discord API docs](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks).

Alternatively, you can publish the config file with:

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

This is the contents of the published config file:

```
return [
    /*
     * The webhook URLs that we'll use to send a message to Discord.
     */
    'webhook_urls' => [
        'default' => env('DISCORD_ALERT_WEBHOOK'),
    ],

    /*
     * Default avatar is an empty string '' which means it will not be included in the payload.
     * You can add multiple custom avatars and then specify directly with withAvatar()
     */
    'avatar_urls' => [
        'default' => '',
    ],

    /*
     * This job will send the message to Discord. You can extend this
     * job to set timeouts, retries, etc...
     */
    'job' => Spatie\DiscordAlerts\Jobs\SendToDiscordChannelJob::class,

    /*
     * It is possible to specify the queue connection that should be used to send the alert.
     */
    'queue_connection' => 'redis',
];
```

Usage
-----

[](#usage)

To send a message to Discord, simply call `DiscordAlert::message()` and pass it any message you want.

```
DiscordAlert::message("You have a new subscriber to the {$newsletter->name} newsletter!");
```

Sending an embed
----------------

[](#sending-an-embed)

To send an embed you can call the same function as above. Just add the embed as a second array as following:

```
DiscordAlert::message("You have a new subscriber to the {$newsletter->name} newsletter!", [
    [
        'title' => 'My title',
        'description' => 'My description',
        'color' => '#E77625',
        'author' => [
            'name' => 'Spatie',
            'url' => 'https://spatie.be/'
        ]
    ]
]);
```

You can also send multiple embeds as one message. Just be careful that you don't hit the limit of Discord.

Changing webhook username/avatar/tts
------------------------------------

[](#changing-webhook-usernameavatartts)

Add/change the functions before invoking the message. `DiscordAlert::message()`tts is false by default. You can add multiple custom avatars in the config file (same as multiple webhooks).

```
DiscordAlert::withUsername('Test')->enableTTS('true')->withAvatar('custom')->message("You have a new subscriber to the {$newsletter->name} newsletter!");
```

Using multiple webhooks
-----------------------

[](#using-multiple-webhooks)

You can also use an alternative webhook, by specify extra ones in the config file.

```
// in config/discord-alerts.php

'webhook_urls' => [
    'default' => 'https://hooks.discord.com/services/XXXXXX',
    'marketing' => 'https://hooks.discord.com/services/YYYYYY',
],
```

The webhook to be used can be chosen using the `to` function.

```
use Spatie\DiscordAlerts\Facades\DiscordAlert;

DiscordAlert::to('marketing')->message("You have a new subscriber to the {$newsletter->name} newsletter!");
```

### Using a custom webhooks

[](#using-a-custom-webhooks)

The `to` function also supports custom webhook urls.

```
use Spatie\DiscordAlerts\Facades\DiscordAlert;

DiscordAlert::to('https://custom-url.com')->message("You have a new subscriber to the {$newsletter->name} newsletter!");
```

### Using the delay feature

[](#using-the-delay-feature)

The `delayMinutes` of the `delayHours` function can be used to delay the message to Discord and can be used in parallel.

```
use Spatie\DiscordAlerts\Facades\DiscordAlert;

DiscordAlert::to('https://custom-url.com')->delayMinutes(5)->message("You have a new subscriber to the {$newsletter->name} newsletter!");
DiscordAlert::to('https://custom-url.com')->delayHours(1)->message("You have a new subscriber to the {$newsletter->name} newsletter!");

DiscordAlert::to('https://custom-url.com')->delayHours(1)->delayMinutes(10)->message("You have a new subscriber to the {$newsletter->name} newsletter!");
```

Formatting
----------

[](#formatting)

### Markdown

[](#markdown)

You can format your messages with markup. Learn how [in the Discord API docs](https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline-).

```
use Spatie\DiscordAlerts\Facades\DiscordAlert;

DiscordAlert::message("A message **with some bold statements** and _some italicized text_.");
```

### Emoji's

[](#emojis)

You can use the same emoji codes as in Discord. This means custom emoji's are also supported.

```
use Spatie\DiscordAlerts\Facades\DiscordAlert;

DiscordAlert::message(":smile: :custom-code:");
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Rias Van der Veken](https://github.com/Riasvdv)
- [Niels Vanpachtenbeke](https://github.com/Nielsvanpach)
- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance46

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor3

3 contributors hold 50%+ of commits

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

412d ago

### Community

Maintainers

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

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (31 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (20 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (14 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (13 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (10 commits)")[![21p-tb](https://avatars.githubusercontent.com/u/57528307?v=4)](https://github.com/21p-tb "21p-tb (5 commits)")[![nssnl](https://avatars.githubusercontent.com/u/255468?v=4)](https://github.com/nssnl "nssnl (4 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (4 commits)")[![igoptx](https://avatars.githubusercontent.com/u/8494829?v=4)](https://github.com/igoptx "igoptx (4 commits)")[![alessandrodorazio](https://avatars.githubusercontent.com/u/18699918?v=4)](https://github.com/alessandrodorazio "alessandrodorazio (3 commits)")[![brunomers11](https://avatars.githubusercontent.com/u/197364589?v=4)](https://github.com/brunomers11 "brunomers11 (3 commits)")[![Maxlego08](https://avatars.githubusercontent.com/u/32517160?v=4)](https://github.com/Maxlego08 "Maxlego08 (1 commits)")[![rico-vz](https://avatars.githubusercontent.com/u/107053109?v=4)](https://github.com/rico-vz "rico-vz (1 commits)")[![dennisvandalen](https://avatars.githubusercontent.com/u/4375758?v=4)](https://github.com/dennisvandalen "dennisvandalen (1 commits)")[![zepfietje](https://avatars.githubusercontent.com/u/44533235?v=4)](https://github.com/zepfietje "zepfietje (1 commits)")[![FinnPaes](https://avatars.githubusercontent.com/u/71390226?v=4)](https://github.com/FinnPaes "FinnPaes (1 commits)")[![clydesantiago](https://avatars.githubusercontent.com/u/31274021?v=4)](https://github.com/clydesantiago "clydesantiago (1 commits)")[![Jamesclark32](https://avatars.githubusercontent.com/u/13315960?v=4)](https://github.com/Jamesclark32 "Jamesclark32 (1 commits)")[![localhousee](https://avatars.githubusercontent.com/u/32237745?v=4)](https://github.com/localhousee "localhousee (1 commits)")

---

Tags

spatielaravellaravel-discord-alerts

###  Code Quality

TestsPest

Static AnalysisPHPStan

### Embed Badge

![Health badge](/badges/maxlego08-laravel-discord-alerts/health.svg)

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[spatie/laravel-discord-alerts

Send a message to Discord

151408.0k](/packages/spatie-laravel-discord-alerts)[spatie/laravel-slack-alerts

Send a message to Slack

3212.6M4](/packages/spatie-laravel-slack-alerts)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[spatie/laravel-onboard

A Laravel package to help track user onboarding steps

808342.9k1](/packages/spatie-laravel-onboard)

PHPackages © 2026

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