mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Constants\FeatureConstants;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Notification;
|
|
use Laravel\Pennant\Feature;
|
|
use NotificationChannels\Discord\DiscordChannel;
|
|
use NotificationChannels\Discord\DiscordMessage;
|
|
|
|
class DiscordNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(protected readonly DiscordMessage $message) {}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
*
|
|
* @noinspection PhpUnusedParameterInspection
|
|
*/
|
|
public function via(mixed $notifiable): array
|
|
{
|
|
return [DiscordChannel::class];
|
|
}
|
|
|
|
/**
|
|
* Get the discord representation of the notification.
|
|
*
|
|
* @noinspection PhpUnusedParameterInspection
|
|
*/
|
|
public function toDiscord(mixed $notifiable): DiscordMessage
|
|
{
|
|
return $this->message;
|
|
}
|
|
|
|
/**
|
|
* Determines if the notification can be sent.
|
|
*
|
|
* @noinspection PhpUnusedParameterInspection
|
|
*/
|
|
public function shouldSend(mixed $notifiable, string $channel): bool
|
|
{
|
|
return Feature::for(null)->active(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
|
}
|
|
}
|