- How do I send a Discord alert from a Laravel event listener?
- Use the `DiscordAlert` facade inside your event listener. For example, in your `UserRegistered` listener, call `DiscordAlert::message('New user registered: ' . $user->name)`. The package automatically queues the job for async processing.
- Does this package support rich embeds or custom Discord message formatting?
- Yes, you can customize embeds via the `config/discord-alerts.php` file or by extending the `DiscordAlert` facade. Use methods like `embed()` to add fields, thumbnails, or timestamps. Check the [README](https://github.com/spatie/laravel-discord-alerts) for examples.
- What Laravel versions are officially supported?
- The package is tested for Laravel 9+ and requires PHP 8.1+. While it may work on older versions (e.g., Laravel 8 with PHP 8.0), Spatie does not guarantee compatibility. Always test in a staging environment before upgrading.
- How do I handle failed Discord alerts (e.g., API rate limits or downtime)?
- Failed jobs are retried by Laravel’s queue system (configurable via `QUEUE_CONNECTION`). Monitor failed jobs in the `failed_jobs` table or use Laravel Horizon for visibility. For critical alerts, consider adding fallback notifications (e.g., email) via event listeners.
- Can I use this package with a Discord bot token instead of a webhook?
- Yes, configure either `DISCORD_WEBHOOK_URL` or `DISCORD_BOT_TOKEN` in your `.env`. The package supports both methods, but webhooks are simpler for one-off alerts. Bots require additional setup (e.g., OAuth2 permissions) for interactive features.
- Will this package work with Laravel Horizon for queue monitoring?
- Absolutely. Since the package uses Laravel’s queue system, Horizon will track job progress, failures, and throughput. Ensure your `QUEUE_CONNECTION` in `.env` points to `redis` or another Horizon-supported driver.
- How do I secure Discord credentials across dev/staging/prod environments?
- Store `DISCORD_WEBHOOK_URL` or `DISCORD_BOT_TOKEN` in environment variables (`.env`). For production, use a secrets manager (e.g., AWS Secrets Manager, Vault) and load them dynamically via Laravel’s `env()` helper or a custom config loader.
- Is there a way to log sent Discord alerts for audit purposes?
- The package doesn’t include built-in logging, but you can log alerts manually by wrapping `DiscordAlert::message()` in a `try-catch` block or using Laravel’s logging facade. For example, `Log::info('Discord alert sent', ['message' => $message])`.
- What happens if Discord’s API changes or goes down during high alert volume?
- The package uses Laravel’s queue system to retry failed jobs. For high-volume alerts, ensure your queue worker (`queue:work`) can handle backpressure (e.g., scale horizontally with Redis). Monitor Discord’s [status page](https://discordstatus.com/) for outages.
- Are there alternatives to this package for sending Laravel alerts to Discord?
- Yes, alternatives include custom solutions using the [Discord API](https://discord.com/developers/docs/resources/webhook) directly or third-party packages like `laravel-discord-notifications`. However, Spatie’s package offers deeper Laravel integration (events, queues) and active maintenance.