2023-05-19 17:01:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
2023-09-14 08:12:44 +00:00
|
|
|
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
|
2023-05-19 17:01:56 +00:00
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
|
2024-06-10 20:43:34 +00:00
|
|
|
class SendMessageToDiscordJob implements ShouldBeEncrypted, ShouldQueue
|
2023-05-19 17:01:56 +00:00
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of times the job may be attempted.
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
public $tries = 5;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-04-30 13:06:49 +00:00
|
|
|
public $backoff = 10;
|
2023-05-19 17:01:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The maximum number of unhandled exceptions to allow before failing.
|
|
|
|
*/
|
2024-04-30 13:06:49 +00:00
|
|
|
public int $maxExceptions = 5;
|
2023-05-19 17:01:56 +00:00
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
public string $text,
|
|
|
|
public string $webhookUrl
|
2023-08-11 18:48:52 +00:00
|
|
|
) {
|
2023-06-21 08:48:43 +00:00
|
|
|
}
|
2023-05-19 17:01:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*/
|
|
|
|
public function handle(): void
|
|
|
|
{
|
|
|
|
$payload = [
|
|
|
|
'content' => $this->text,
|
|
|
|
];
|
|
|
|
Http::post($this->webhookUrl, $payload);
|
|
|
|
}
|
|
|
|
}
|