2023-05-19 17:01:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
|
|
|
|
class SendMessageToDiscordJob implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of times the job may be attempted.
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
public $tries = 5;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The maximum number of unhandled exceptions to allow before failing.
|
|
|
|
*/
|
|
|
|
public int $maxExceptions = 3;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
public string $text,
|
|
|
|
public string $webhookUrl
|
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,
|
|
|
|
];
|
2023-06-21 08:48:43 +00:00
|
|
|
ray($payload);
|
2023-05-19 17:01:56 +00:00
|
|
|
Http::post($this->webhookUrl, $payload);
|
|
|
|
}
|
|
|
|
}
|